fix(fe2): less frequent cookie-fix invocation (#3841)
This commit is contained in:
committed by
GitHub
parent
58abe11948
commit
e89a131ffc
@@ -12,6 +12,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useTheme } from '~~/lib/core/composables/theme'
|
||||
import { useAuthManager } from '~~/lib/auth/composables/auth'
|
||||
import { useFixBraveSafariCookies } from '~~/lib/common/composables/reactiveCookie'
|
||||
|
||||
const { isDarkTheme } = useTheme()
|
||||
|
||||
@@ -30,6 +31,7 @@ useHead({
|
||||
|
||||
const { watchAuthQueryString } = useAuthManager()
|
||||
watchAuthQueryString()
|
||||
useFixBraveSafariCookies()
|
||||
</script>
|
||||
<style>
|
||||
.page-enter-active,
|
||||
|
||||
@@ -5,9 +5,6 @@ import dayjs from 'dayjs'
|
||||
import { useScopedState } from '~~/lib/common/composables/scopedState'
|
||||
import { isUndefined } from 'lodash-es'
|
||||
import { isBraveOrSafari } from '@speckle/shared'
|
||||
import { abortControllerManager, isAbortError } from '~/lib/common/utils/requests'
|
||||
|
||||
const aborts = abortControllerManager()
|
||||
|
||||
/**
|
||||
* Makes useCookie() synchronized across the app so that a change to it from one place
|
||||
@@ -43,16 +40,6 @@ export const useSynchronizedCookie = <CookieValue = string>(
|
||||
} else {
|
||||
tmpCookie.value = undefined
|
||||
}
|
||||
|
||||
// Fetch w/ abort of previous call, if any
|
||||
const controller = aborts.popOnlyInCSR()
|
||||
void fetch('/web-api/cookie-fix', {
|
||||
signal: controller?.signal
|
||||
}).catch((e) => {
|
||||
if (!isAbortError(e)) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -64,3 +51,11 @@ export const useSynchronizedCookie = <CookieValue = string>(
|
||||
|
||||
return cookie
|
||||
})
|
||||
|
||||
export const useFixBraveSafariCookies = () => {
|
||||
if (!import.meta.client || !isBraveOrSafari()) return
|
||||
|
||||
onMounted(async () => {
|
||||
await fetch('/web-api/cookie-fix')
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user