diff --git a/packages/frontend/src/ui/_common_/stream-indicator.vue b/packages/frontend/src/ui/_common_/stream-indicator.vue index abeb66c326..d252496829 100644 --- a/packages/frontend/src/ui/_common_/stream-indicator.vue +++ b/packages/frontend/src/ui/_common_/stream-indicator.vue @@ -24,12 +24,17 @@ import { defaultStore } from '@/store'; const zIndex = os.claimZIndex('high'); let hasDisconnected = $ref(false); +let timeoutId = $ref(); function onDisconnected() { - hasDisconnected = true; + window.clearTimeout(timeoutId); + timeoutId = window.setTimeout(() => { + hasDisconnected = true; + }, 1000 * 10); } function resetDisconnected() { + window.clearTimeout(timeoutId); hasDisconnected = false; } @@ -37,9 +42,12 @@ function reload() { location.reload(); } +useStream().on('_connected_', resetDisconnected); useStream().on('_disconnected_', onDisconnected); onUnmounted(() => { + window.clearTimeout(timeoutId); + useStream().off('_connected_', resetDisconnected); useStream().off('_disconnected_', onDisconnected); });