fix: prevent reloading page (#2973)

This commit is contained in:
Joaquín Sánchez 2024-09-23 18:08:02 +02:00 committed by GitHub
parent fe58a2b522
commit 54344acf4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 // when multiple tabs: we need to reload window when sign in, switch account or sign out
if (import.meta.client) { 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 = () => { const windowReload = () => {
if (document.visibilityState === 'visible') if (document.visibilityState === 'visible' && !initialLoad.value)
window.location.reload() window.location.reload()
} }
watch(currentUserHandle, async (handle, oldHandle) => { watch(currentUserHandle, async (handle, oldHandle) => {