Hello,
I'm having a lot of trouble updating the gantt data after every changes. We're trying to make a realtime feature where multiple users can look at the gantt and see the changes of everybody else in realtime. Right now it's working well for a single user because we feed the data the first time and then the gantt works by itself but the changes are not reflected to the other users until they refresh the whole page.
export const projectModel = new ProjectModel({
validateResponse: true,
autoSync: true,
});
// in the react component
const ganttResult = useGanttDataByProjectIdSubscription({ // graphql subscription
variables: {
projectId,
},
fetchPolicy: 'no-cache',
});
const project = ganttResult.data?.project;
// ...
useEffect(() => {
if (project) { // if the project is loaded
projectModel.id = project.id;
projectModel.startDate = project.start;
projectModel.endDate = project.end;
const inlineData = {
eventsData: [...],
dependenciesData: [...],
};
projectModel.inlineData = inlineData
}
}, [project]);
// ...
<BryntumGantt
{...ganttConfig}
features={{
...ganttConfig.features,
criticalPaths: { disabled: !criticalPathEnabled },
}}
columns={columns}
project={projectModel}
ref={ganttRef}
/>
The logic is that everytime the gantt is updated, we're doing a server call, saving the data and when the data comes back, we update the gantt. We're not using the Crud Manager, we're saving the data everytime there is a sync (by listening to a beforeSync event). inlineData
seems to be working the first time when the data is loaded but after that, every update does nothing at all, no error.
I tried a solution where I was removing all the listener, removing all the data from both stores and adding back the new data using removeAll()
and looping to do insert
but I don't think that's the right solution.
Not sure if this is really related to React of if there is something fundamental that I don't understand about inlineData
and how to handle the project model and the data. I have many other problems related to this that I will discuss in other posts.
Thanks for the help