Skip to content

Commit

Permalink
fix: prevent reloading page (#2973)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin authored and shuuji3 committed Oct 21, 2024
1 parent 7a851f9 commit bdb2643
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion composables/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ export const isGlitchEdition = computed(() => currentInstance.value?.version?.in

// when multiple tabs: we need to reload window when sign in, switch account or sign out
if (import.meta.client) {
// fix #2972: now users loaded from idb, we need to wait for it
const initialLoad = ref(true)
watchOnce(users, () => {
initialLoad.value = false
}, { immediate: true, flush: 'sync' })

const windowReload = () => {
if (document.visibilityState === 'visible')
if (document.visibilityState === 'visible' && !initialLoad.value)
window.location.reload()
}
watch(currentUserHandle, async (handle, oldHandle) => {
Expand Down

0 comments on commit bdb2643

Please sign in to comment.