Skip to content

Commit

Permalink
fix: refresh content on reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed May 31, 2024
1 parent 2248387 commit 52442fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/app-frontend/src/features/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineComponent({
},
setup() {
const { isConnected, isInitializing, showDisplayDisconnected } = useAppConnection()
const { isConnected, isInitializing, showDisplayDisconnected, connectedTimes } = useAppConnection()
function updateTheme(theme: string) {
if (theme === 'dark' || theme === 'high-contrast' || (theme === 'auto' && chromeTheme === 'dark')) {
Expand Down Expand Up @@ -81,6 +81,7 @@ export default defineComponent({
isConnected,
isInitializing,
showDisplayDisconnected,
connectedTimes,
showAppsSelector,
orientation,
isChrome,
Expand All @@ -91,10 +92,9 @@ export default defineComponent({

<template>
<div
class="app w-full h-full flex relative outline-none"
class="app w-full h-full relative outline-none"
:class="{
'disconnected pointer-events-none': !isInitializing && !isConnected,
'flex-col': orientation === 'portrait',
}"
tabindex="0"
>
Expand All @@ -108,7 +108,14 @@ export default defineComponent({
class="absolute inset-0"
/>

<template v-else>
<div
v-else
:key="connectedTimes"
class="w-full h-full flex"
:class="{
'flex-col': orientation === 'portrait',
}"
>
<AppHeader class="flex-none relative z-10 border-b border-gray-200 dark:border-gray-700" />

<SplitPane
Expand All @@ -129,7 +136,7 @@ export default defineComponent({
<router-view class="h-full overflow-auto" />
</template>
</SplitPane>
</template>
</div>

<TeleportTarget id="root" />

Expand Down
5 changes: 5 additions & 0 deletions packages/app-frontend/src/features/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useNow } from '@vueuse/core'
const isConnected = ref(false)
const isInitializing = ref(true)
const lastDisconnect = ref(0)
const connectedTimes = ref(0)

export function useAppConnection() {
const now = useNow({
Expand All @@ -25,6 +26,7 @@ export function useAppConnection() {
isInitializing,
lastDisconnect,
showDisplayDisconnected,
connectedTimes,
}
}

Expand All @@ -36,6 +38,9 @@ export function setAppConnected(value: boolean, force = false) {
lastDisconnect.value = Date.now()
}
isConnected.value = value
if (value) {
connectedTimes.value++
}
}

export function setAppInitializing(value: boolean) {
Expand Down

0 comments on commit 52442fe

Please sign in to comment.