IO-2924 add state sync on reconnect, correct treatment, and add status.
This commit is contained in:
@@ -47,7 +47,7 @@ function ProductionBoardKanbanContainer({ bodyshop, currentUser, subscriptionTyp
|
||||
onError: (error) => console.error(`Error fetching jobs in production: ${error.message}`)
|
||||
});
|
||||
|
||||
const subscriptionEnabled = Websocket_Production?.treatment === "on";
|
||||
const subscriptionEnabled = Websocket_Production?.treatment === "off";
|
||||
|
||||
const { data: updatedJobs } = useSubscription(
|
||||
subscriptionType === "view" ? SUBSCRIPTION_JOBS_IN_PRODUCTION_VIEW : SUBSCRIPTION_JOBS_IN_PRODUCTION,
|
||||
@@ -126,14 +126,19 @@ function ProductionBoardKanbanContainer({ bodyshop, currentUser, subscriptionTyp
|
||||
}
|
||||
};
|
||||
|
||||
const handleReconnect = () => {
|
||||
//If we were disconnected from the board, we missed stuff. We need to refresh it entirely.
|
||||
if (refetch) refetch();
|
||||
};
|
||||
// Listen for 'job-changed' events
|
||||
socket.on("production-job-updated", handleJobUpdates);
|
||||
|
||||
socket.on("reconnect", handleReconnect);
|
||||
// Clean up on unmount or when dependencies change
|
||||
return () => {
|
||||
socket.off("production-job-updated", handleJobUpdates);
|
||||
socket.off("reconnect", handleReconnect);
|
||||
};
|
||||
}, [subscriptionEnabled, socket, bodyshop, data, client]);
|
||||
}, [subscriptionEnabled, socket, bodyshop, data, client, refetch]);
|
||||
|
||||
const filteredAssociationSettings = useMemo(() => {
|
||||
return associationSettings?.associations[0] || null;
|
||||
|
||||
Reference in New Issue
Block a user