From 383ca37e5c63a7a835a2fe182e7c6b7c0348ea10 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Tue, 8 Sep 2026 11:45:30 +0000 Subject: [PATCH 1/3] fix: refresh profile on window focus --- apps/lachesis/app/composables/clotho/useAuth.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/lachesis/app/composables/clotho/useAuth.ts b/apps/lachesis/app/composables/clotho/useAuth.ts index 80fb2d9..2a7f736 100644 --- a/apps/lachesis/app/composables/clotho/useAuth.ts +++ b/apps/lachesis/app/composables/clotho/useAuth.ts @@ -4,7 +4,11 @@ export const useAuth = () => { const { $api, $queryClient } = useNuxtApp() const token = useCookie('auth_token', { maxAge: 60 * 60 * 24 * 365 /* one year */ }) - const userQuery = useQuery($api.account.profile.show.queryOptions()) + const userQuery = useQuery( + $api.account.profile.show.queryOptions(undefined, { + refetchOnWindowFocus: (query) => query.state.data?.data?.emailVerified !== true, + }) + ) const user = computed(() => userQuery.data.value?.data) const loginMutation = useMutation( From 78769630dc70c34458f1e14c83fb5129896453df Mon Sep 17 00:00:00 2001 From: Ahmed Date: Tue, 8 Sep 2026 17:04:29 +0000 Subject: [PATCH 2/3] fix: remove redundant optional chaining in auth refresh --- apps/lachesis/app/composables/clotho/useAuth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/lachesis/app/composables/clotho/useAuth.ts b/apps/lachesis/app/composables/clotho/useAuth.ts index 2a7f736..b1a4311 100644 --- a/apps/lachesis/app/composables/clotho/useAuth.ts +++ b/apps/lachesis/app/composables/clotho/useAuth.ts @@ -6,7 +6,7 @@ export const useAuth = () => { const token = useCookie('auth_token', { maxAge: 60 * 60 * 24 * 365 /* one year */ }) const userQuery = useQuery( $api.account.profile.show.queryOptions(undefined, { - refetchOnWindowFocus: (query) => query.state.data?.data?.emailVerified !== true, + refetchOnWindowFocus: (query) => query.state.data?.data.emailVerified !== true, }) ) const user = computed(() => userQuery.data.value?.data) From 1d2cb3d320c1921b4c3d925b62ee8e8bf7aa72e6 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 9 Sep 2026 06:23:14 +0000 Subject: [PATCH 3/3] fix: refetch on native window focus in the app tanstack's stock focus listener subscribes to `visibilitychange` only, so returning to a browser tab revalidates but a tauri window regaining native focus while it stays visible does not. listen for `tauri://focus` and push that focus into the focus manager, then set it back to undefined so detection is handed straight back to the library default. --- apps/lachesis/app/plugins/focus.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 apps/lachesis/app/plugins/focus.ts diff --git a/apps/lachesis/app/plugins/focus.ts b/apps/lachesis/app/plugins/focus.ts new file mode 100644 index 0000000..a576f4e --- /dev/null +++ b/apps/lachesis/app/plugins/focus.ts @@ -0,0 +1,17 @@ +import { focusManager } from '@tanstack/vue-query' +import { isTauri } from '@tauri-apps/api/core' +import { listen, TauriEvent } from '@tauri-apps/api/event' + +// tanstack's stock focus listener watches `visibilitychange` only, so the app +// window regaining native focus while it stays visible never revalidates. push +// that focus in, then hand detection straight back to the default. +export default defineNuxtPlugin({ + name: 'focus', + setup() { + if (!isTauri()) return + listen(TauriEvent.WINDOW_FOCUS, () => { + focusManager.setFocused(true) + focusManager.setFocused(undefined) + }) + }, +})