Merged in feature/IO-3255-simplified-part-management (pull request #2504)

feature/IO-3255-simplified-parts-management - Bug changes / Socket close cleanup
This commit is contained in:
Dave Richer
2025-08-22 18:26:38 +00:00
2 changed files with 15 additions and 16 deletions

View File

@@ -64,7 +64,7 @@ export default function ShopInfoContainer() {
onFinish={handleFinish} onFinish={handleFinish}
initialValues={ initialValues={
data data
? data.bodyshops[0].accountingconfig.ClosingPeriod ? data?.bodyshops?.[0]?.accountingconfig?.ClosingPeriod
? { ? {
...data.bodyshops[0], ...data.bodyshops[0],
accountingconfig: { accountingconfig: {

View File

@@ -167,7 +167,7 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
socketRef.current = socketInstance; socketRef.current = socketInstance;
const handleBodyshopMessage = (message) => { const handleBodyshopMessage = (message) => {
if (!message || !message.type) return; if (!message?.type) return;
switch (message.type) { switch (message.type) {
case "alert-update": case "alert-update":
store.dispatch(addAlerts(message.payload)); store.dispatch(addAlerts(message.payload));
@@ -512,21 +512,20 @@ const SocketProvider = ({ children, bodyshop, navigate, currentUser }) => {
}; };
const unsubscribe = auth.onIdTokenChanged(async (user) => { const unsubscribe = auth.onIdTokenChanged(async (user) => {
if (user) { if (!user) {
const token = await user.getIdToken(); socketRef.current?.disconnect();
if (socketRef.current) { socketRef.current = null;
socketRef.current.emit("update-token", { token, bodyshopId: bodyshop.id }); setIsConnected(false);
} else { return;
initializeSocket(token).catch((err) => }
console.error(`Something went wrong Initializing Sockets: ${err?.message || ""}`)
); const token = await user.getIdToken();
} if (socketRef.current) {
socketRef.current.emit("update-token", { token, bodyshopId: bodyshop.id });
} else { } else {
if (socketRef.current) { initializeSocket(token).catch((err) =>
socketRef.current.disconnect(); console.error("Something went wrong Initializing Sockets:", err?.message || "")
socketRef.current = null; );
setIsConnected(false);
}
} }
}); });