@@ -6,7 +6,7 @@ import { computed, onMounted, watch, watchEffect } from 'vue'
66import { getColorMode , showConnectionWarning , useClient , useInjectionClient } from ' ~/composables/client'
77import { devAuthToken , isDevAuthed } from ' ~/composables/dev-auth'
88import { useCopy } from ' ~/composables/editor'
9- import { rpc } from ' ~/composables/rpc'
9+ import { rpc , WS_DEBOUNCE_TIME } from ' ~/composables/rpc'
1010import { registerCommands } from ' ~/composables/state-commands'
1111import { splitScreenAvailable , splitScreenEnabled } from ' ~/composables/storage'
1212import { useSchemaInput } from ' ./composables/state-schema'
@@ -45,6 +45,27 @@ const route = useRoute()
4545const colorMode = getColorMode ()
4646const isUtilityView = computed (() => route .path .startsWith (' /__' ) || route .path === ' /' )
4747const waiting = computed (() => ! client .value && ! showConnectionWarning .value )
48+ const showDisconnectIndicator = ref (false )
49+
50+ if (wsConnectedOnce .value ) {
51+ // debounce one time to avoid showing the indicator on first load of the app
52+ onConnected ()
53+ }
54+ else {
55+ // watch for connection and show the indicator if it was connected at least once
56+ const stop = watch (wsConnectedOnce , (val ) => {
57+ if (val ) {
58+ onConnected ()
59+ stop ()
60+ }
61+ })
62+ }
63+
64+ function onConnected() {
65+ setTimeout (() => {
66+ showDisconnectIndicator .value = true
67+ }, WS_DEBOUNCE_TIME )
68+ }
4869
4970watch (
5071 () => client .value ?.app .colorMode .value ,
@@ -153,7 +174,7 @@ registerCommands(() => [
153174 <CommandPalette />
154175 <AuthConfirmDialog />
155176 </div >
156- <DisconnectIndicator />
177+ <DisconnectIndicator v-if = " showDisconnectIndicator " />
157178 <RestartDialogs />
158179 <div v-lazy-show =" dataSchema" >
159180 <LazyDataSchemaDrawer />
0 commit comments