Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/lachesis/app/composables/clotho/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
17 changes: 17 additions & 0 deletions apps/lachesis/app/plugins/focus.ts
Original file line number Diff line number Diff line change
@@ -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)
})
},
})