implemented #76

This commit is contained in:
PxlLoewe
2025-07-23 19:06:35 -07:00
parent 115296d7f7
commit 0b0f4fac2f
6 changed files with 45 additions and 6 deletions

View File

@@ -11,7 +11,13 @@ interface ConnectionStore {
message: string;
selectedZone: string;
logoffTime: string;
connect: (uid: string, selectedZone: string, logoffTime: string) => Promise<void>;
ghostMode: boolean;
connect: (
uid: string,
selectedZone: string,
logoffTime: string,
ghostMode: boolean,
) => Promise<void>;
disconnect: () => void;
}
@@ -23,11 +29,12 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
message: "",
selectedZone: "LST_01",
logoffTime: "",
connect: async (uid, selectedZone, logoffTime) =>
ghostMode: false,
connect: async (uid, selectedZone, logoffTime, ghostMode) =>
new Promise((resolve) => {
set({ status: "connecting", message: "" });
dispatchSocket.auth = { uid };
set({ selectedZone, logoffTime });
set({ selectedZone, logoffTime, ghostMode });
dispatchSocket.connect();
dispatchSocket.once("connect", () => {
@@ -40,11 +47,12 @@ export const useDispatchConnectionStore = create<ConnectionStore>((set) => ({
}));
dispatchSocket.on("connect", () => {
const { logoffTime, selectedZone } = useDispatchConnectionStore.getState();
const { logoffTime, selectedZone, ghostMode } = useDispatchConnectionStore.getState();
useAudioStore.getState().connect("LST_01", selectedZone || "Leitstelle");
dispatchSocket.emit("connect-dispatch", {
logoffTime,
selectedZone,
ghostMode,
});
useDispatchConnectionStore.setState({ status: "connected", message: "" });
});