Skip to content

Commit

Permalink
fix: ios ws reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Mar 18, 2023
1 parent ce2680d commit 6c04a38
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions web/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function useWS(radioUUID: Accessor<string>): WSReturn {
const [connecting, setConnecting] = createSignal(true);
const [connected, setConnected] = createSignal(false);
const [disconnected, setDisconnected] = createSignal(false);
const [shouldReconnect, setShouldReconnect] = createSignal(false);

const [stale, setStale] = createSignal<ModelStale | undefined>(undefined, {
equals: false,
Expand All @@ -93,6 +94,7 @@ export function useWS(radioUUID: Accessor<string>): WSReturn {
setConnecting(false);
setConnected(true);
setDisconnected(false);
setShouldReconnect(false);
});
sendCommand(ws, radioUUID());
});
Expand Down Expand Up @@ -123,6 +125,7 @@ export function useWS(radioUUID: Accessor<string>): WSReturn {
setConnected(false);
setDisconnected(true);
setState(DefaultState);
setShouldReconnect(true);
});
});

Expand Down Expand Up @@ -159,6 +162,16 @@ export function useWS(radioUUID: Accessor<string>): WSReturn {
)
);

createEffect(
on(
shouldReconnect,
() => {
if (shouldReconnect()) reconnect();
},
{ defer: true }
)
);

return [
{
state,
Expand Down

0 comments on commit 6c04a38

Please sign in to comment.