fix: refresh profile after email verification - #27
Conversation
|
Superseded. This PR has been rewritten as a single independent change against current The earlier branch was based on |
260fe99 to
5a576a7
Compare
|
tanstack's refetchOnFocus should do this ? |
5a576a7 to
383ca37
Compare
|
Yes — that's all it needed. It's now just a per-query Dropped the global focus listener and the token guards, so this is one file now. One thing worth flagging: 5.102.8's default focus listener subscribes to |
|
Correct, but data?.data? is redundant, data?.data.xxx is correct ps. ur correct, it won't work for an app, and the fix is specified in the respective docs |
|
Fixed in 7876963 — dropped the inner |
|
Sorry, I skipped your second line. You're right, and thanks for the pointer: https://tanstack.com/query/latest/docs/framework/react/guides/window-focus-refetching#custom-window-focus-event — for the desktop app the documented fix is Happy to open that as its own PR if you want it. Keeping it out of this one. |
|
Added it here in 1cd8a21 rather than a separate PR, since you said this is what's blocking the merge — say the word if you'd rather have it split and I'll move it out.
Typecheck and lint pass. Description updated with the baseline. |
|
why not listen to https://v2.tauri.app/reference/javascript/api/namespaceevent/#window_focus and run focusManager.setFocused ? |
1cd8a21 to
12f6bb9
Compare
|
Done, 103338a — much better, thanks. if (isTauri()) {
listen(TauriEvent.WINDOW_FOCUS, () => {
focusManager.setFocused(true)
focusManager.setFocused(undefined)
})
}
Lachesis typecheck and lint are clean. |
12f6bb9 to
103338a
Compare
|
focusManager modification shouldn't be inside the clotho plugin, it's out of scope for that file. and also, this needs testing. |
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.
103338a to
1d2cb3d
Compare
|
Fair, moving it into its own plugin now — clotho.ts goes back to untouched. On testing, what did you have in mind? There's no test runner in the repo, so I didn't want to drag vitest in for eight lines without asking first. And I can't trigger a real tauri window focus from where I'm working, so I can't honestly say I've verified it — only that the browser path behaves as expected. Happy to do either, just say which. |
|
Moved — 1d2cb3d. It's |
|
no rush — just flagging the testing question is still open on my side. if you meant an automated test, the blocker is there's no runner in the repo, so it'd mean adding vitest + happy-dom for two files. happy to do it if you want it, but that's a bigger change than the fix and I didn't want to sneak it in. if you meant you'll just try it yourself: build, open a second window, verify the email, click back onto the app window — banner should clear without a reload. that's the whole thing. whichever you prefer. |
|
Closed in favor of c51beb8 |
An unverified user can verify in another tab or window while an open Lachesis window keeps the stale profile, so its banner and gates remain visible.
The fix, two parts.
useAuth.tsopts the profile query back in with a conditionalrefetchOnWindowFocus, which stops opting in onceemailVerifiedis true. The query client setsrefetchOnWindowFocus: falseglobally because refetches are manual, so the built-in never fired for this query.A new
plugins/focus.tsfeeds Tauri'swindow_focusevent intofocusManager.setFocused, then hands detection straight back to the default.Why part 2 is needed. Baseline first: with only part 1, against the installed TanStack Query 5.102.8, a focused harness refetched on hidden-to-visible and did not react to a bare
windowfocusevent. The stock listener subscribes tovisibilitychangeonly. So the browser tab-return path already worked, and the app window regaining native focus while it stays visible did not.The library's own focus listener is left exactly as it ships.
setFocused(true)reports the one signal it cannot see, andsetFocused(undefined)immediately returns detection to the default rather than pinning it to a manual value.Scope.
refetchOnWindowFocus: falseandrefetchOnMount: falsestay as they are.plugins/clotho.tsis untouched. This changes when focus is observed, not which queries react to it, so no query other than the profile one is affected. No new dependencies;@tauri-apps/apiis already used for this.Not verified on a desktop build. The browser path was measured; a real Tauri native focus event has not been exercised.