diff --git a/apps/lachesis/app/composables/clotho/useAuth.ts b/apps/lachesis/app/composables/clotho/useAuth.ts index 80fb2d9..b1a4311 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( 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) + }) + }, +})