fix: the diagnostics tab keeps its focus, its level and its consent
Deep-review round 1 of E22. - After a 429 the stream sent one POST per new event while a full batch waited; it now stays quiet for 15 s. Past the queue cap the oldest events go, as the comment always said, a refused batch included. - A batch refused after the level was lowered came back into the queue of a later consent in the same tab; each consent is its own session. - A `me` fetch that left before a level or preference change could put the old value back for up to a minute. `updateMeCache` writes the cache and cancels that fetch; usePref goes through it too. - The consent box's buttons and "revert now" took the focus with them to <body>; it returns to the level picker. Watched until the button is gone — in Chrome the saved level arrives in two renders, and a one-shot check spent itself on the first (jsdom never showed it). - The countdown line is no longer a live region re-read every minute. - "Saját napló" rows were keyed by index on a newest-first list, so every new event remounted every row and dropped the focus off a row button.
This commit is contained in:
@@ -5,6 +5,7 @@ import { api } from "./api";
|
||||
import type { Me } from "./api/account";
|
||||
import { readAccount, writeAccount } from "./storage";
|
||||
import { notifyActionError } from "./actionErrors";
|
||||
import { updateMeCache } from "./useMe";
|
||||
import i18n from "../i18n";
|
||||
|
||||
// The local state + cache already show the new value, so a refused save is otherwise invisible until
|
||||
@@ -45,9 +46,7 @@ function readServerPref(me: Me | null | undefined, key: string): unknown {
|
||||
// (their sole difference is WHEN the server write fires — immediately vs debounced), so the cache-merge
|
||||
// shape lives in ONE place.
|
||||
function mergePrefsCache(qc: QueryClient, patch: Record<string, unknown>): void {
|
||||
qc.setQueryData<Me | null>(qk.me(), (m) =>
|
||||
m ? { ...m, preferences: { ...m.preferences, ...patch } } : m,
|
||||
);
|
||||
updateMeCache(qc, (m) => ({ ...m, preferences: { ...m.preferences, ...patch } }));
|
||||
}
|
||||
|
||||
/** The raw preference persister: save an arbitrary partial preferences patch to the server and merge
|
||||
|
||||
Reference in New Issue
Block a user