fixed bug that prevented pilots and dispos from receiving socket events after disconnect
This commit is contained in:
@@ -23,13 +23,10 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
||||
new Promise((resolve) => {
|
||||
set({ status: "connecting", message: "" });
|
||||
dispatchSocket.auth = { uid };
|
||||
set({ selectedZone });
|
||||
set({ selectedZone, logoffTime });
|
||||
dispatchSocket.connect();
|
||||
|
||||
dispatchSocket.once("connect", () => {
|
||||
dispatchSocket.emit("connect-dispatch", {
|
||||
logoffTime,
|
||||
selectedZone,
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
}),
|
||||
@@ -39,6 +36,12 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
|
||||
}));
|
||||
|
||||
dispatchSocket.on("connect", () => {
|
||||
const { logoffTime, selectedZone } = useDispatchConnectionStore.getState();
|
||||
|
||||
dispatchSocket.emit("connect-dispatch", {
|
||||
logoffTime,
|
||||
selectedZone,
|
||||
});
|
||||
useDispatchConnectionStore.setState({ status: "connected", message: "" });
|
||||
});
|
||||
|
||||
@@ -61,11 +64,4 @@ dispatchSocket.on("force-disconnect", (reason: string) => {
|
||||
});
|
||||
});
|
||||
|
||||
dispatchSocket.on("reconnect", () => {
|
||||
const { logoffTime, selectedZone } = useDispatchConnectionStore.getState();
|
||||
|
||||
dispatchSocket.emit("connect-dispatch", {
|
||||
logoffTime,
|
||||
selectedZone,
|
||||
});
|
||||
});
|
||||
dispatchSocket.on("reconnect", () => {});
|
||||
|
||||
Reference in New Issue
Block a user