IO-2924 add state sync on reconnect, correct treatment, and add status.

This commit is contained in:
Patrick Fic
2024-09-26 15:03:27 -07:00
parent db0c16f31d
commit 575f056360
9 changed files with 53 additions and 8 deletions

View File

@@ -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;