fix(ui): read board and alerts once on load, not again on the first stream connect
This commit is contained in:
1 file changed
+5
-1
@@ -86,6 +86,9 @@ export const useSessionStore = defineStore("session", () => {
|
||||
// the page reads "Disconnected" until a reload.
|
||||
let retryTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let retryAttempt = 0;
|
||||
// Views read their data on mount, so only a reconnect, which may have
|
||||
// missed events, moves connectionRevision.
|
||||
let connectedOnce = false;
|
||||
|
||||
function connect(): void {
|
||||
clearTimeout(retryTimer);
|
||||
@@ -95,7 +98,8 @@ export const useSessionStore = defineStore("session", () => {
|
||||
streamState.value = state;
|
||||
if (state === "live") {
|
||||
retryAttempt = 0;
|
||||
connectionRevision.value += 1;
|
||||
if (connectedOnce) connectionRevision.value += 1;
|
||||
connectedOnce = true;
|
||||
} else if (state === "unavailable") {
|
||||
retryTimer = setTimeout(connect, reconnectDelay(retryAttempt++));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user