mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
refactor(settings): drop two query keys nothing reads
The unit-system and glucose-unit selects invalidated `userUnitPreference()` and `userGlucoseUnit()` after a save, but no query was ever registered under either key; every surface reads the units from the account payload, which both selects already refresh.
This commit is contained in:
1 parent
5552a9b149
commit
0c07764097
4 files changed
+7
-31
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$comment": "Comment lines that open with a release version, per file under src/. Maintained by src/__tests__/version-stamp-ratchet.test.ts.",
|
||||
"count": 2881,
|
||||
"total": 9185,
|
||||
"total": 9184,
|
||||
"entries": {
|
||||
"__tests__/account-payload-consumer-guard.test.ts": 2,
|
||||
"__tests__/acting-account-boundary-guard.test.ts": 7,
|
||||
@@ -2691,7 +2691,7 @@
|
||||
"lib/queries/use-profile-claim.ts": 4,
|
||||
"lib/query-keys/admin.ts": 12,
|
||||
"lib/query-keys/ai-runs.ts": 1,
|
||||
"lib/query-keys/auth.ts": 9,
|
||||
"lib/query-keys/auth.ts": 8,
|
||||
"lib/query-keys/coach.ts": 13,
|
||||
"lib/query-keys/custom-metrics.ts": 1,
|
||||
"lib/query-keys/cycle.ts": 1,
|
||||
|
||||
@@ -29,9 +29,9 @@ import { resolveGlucoseUnit, type GlucoseUnit } from "@/lib/glucose";
|
||||
* locale.
|
||||
*
|
||||
* Persistence mirrors the unit-system select: a change PATCHes
|
||||
* `/api/auth/me/glucose-unit` immediately and invalidates `queryKeys.authMe()`
|
||||
* plus `queryKeys.userGlucoseUnit()`, so the dashboard tiles, the glucose
|
||||
* insight page and the targets panel re-render on the next /me refetch.
|
||||
* `/api/auth/me/glucose-unit` immediately and invalidates `queryKeys.authMe()`,
|
||||
* so the dashboard tiles and the glucose insight page re-render on the next
|
||||
* /me refetch.
|
||||
*/
|
||||
export function GlucoseUnitSelect({
|
||||
isAuthenticated,
|
||||
@@ -66,9 +66,6 @@ export function GlucoseUnitSelect({
|
||||
onSuccess: () => {
|
||||
toastWrittenOutcome("success", t("settings.dashboard.glucoseUnit.saved"));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.authMe() });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.userGlucoseUnit(),
|
||||
});
|
||||
setOptimistic(null);
|
||||
},
|
||||
onError: (err) => {
|
||||
|
||||
@@ -23,9 +23,8 @@ type UnitPreference = "metric" | "imperial";
|
||||
* picker rather than in a standalone card (it replaces the retired
|
||||
* `<UnitPreferenceCard>`). Persistence is unchanged: a change PATCHes
|
||||
* `/api/auth/me/unit-preference` immediately and invalidates
|
||||
* `queryKeys.authMe()` + `queryKeys.userUnitPreference()` so every chart
|
||||
* display transform (km/h vs mph, km vs mi) re-renders on the next /me
|
||||
* refetch — no manual reload, no contract change.
|
||||
* `queryKeys.authMe()`, the account payload every chart display transform
|
||||
* (km/h vs mph, km vs mi) reads, so they re-render on the next /me refetch.
|
||||
*/
|
||||
export function UnitPreferenceSelect({
|
||||
isAuthenticated,
|
||||
@@ -59,9 +58,6 @@ export function UnitPreferenceSelect({
|
||||
onSuccess: () => {
|
||||
toastWrittenOutcome("success", t("settings.dashboard.units.saved"));
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.authMe() });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: queryKeys.userUnitPreference(),
|
||||
});
|
||||
setOptimistic(null);
|
||||
},
|
||||
onError: (err) => {
|
||||
|
||||
@@ -23,23 +23,6 @@ export const authKeys = {
|
||||
* settings/ai-section, targets/target-edit-sheet).
|
||||
*/
|
||||
userThresholds: () => ["user", "thresholds"] as const,
|
||||
/**
|
||||
* v1.7.0 — Settings → Display metric/imperial control reads its
|
||||
* current value from `GET /api/auth/me/unit-preference`. The PATCH
|
||||
* mutation also invalidates `authMe()` so `useAuth().unitPreference`
|
||||
* (and every chart display transform that keys off it) re-renders
|
||||
* without a manual reload.
|
||||
*/
|
||||
userUnitPreference: () => ["user", "unit-preference"] as const,
|
||||
/**
|
||||
* The mg/dL vs mmol/L glucose display control behind
|
||||
* `GET /api/auth/me/glucose-unit`. A separate axis from the
|
||||
* metric/imperial preference above — metric countries are split on
|
||||
* which one they read glucose in — so it carries its own key. The
|
||||
* PATCH also invalidates `authMe()`, since every glucose surface
|
||||
* resolves the unit from the account payload rather than from here.
|
||||
*/
|
||||
userGlucoseUnit: () => ["user", "glucose-unit"] as const,
|
||||
|
||||
passkeys: () => ["passkeys"] as const,
|
||||
|
||||
|
||||
Reference in new issue
Block a user