mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
The "That day" card took the workout, dropped it, and offered three chips to Pulse, Sleep and Mood. None of those pages accepts a date, so every chip landed on an all-time trend surface with the day nowhere in sight. Replace it with the day itself: the intraday pulse chart pinned to the session's day, the night the person woke from into it, and that day's mood entries. All three reads are addressed by the server-resolved dayKey, so nothing here decides which day a workout belongs to. The two outbound links that remain are undated and say what they lead to, Sleep trends and Mood history. Sleep and the intraday chart mount only when their module is on, so a switched-off module cannot paint as a failed read, and a query that has not answered yet shows a skeleton rather than claiming the night was empty. The detail page also drops the description it borrowed from the list.
79 lines
3.0 KiB
TypeScript
79 lines
3.0 KiB
TypeScript
/**
|
|
* Query keys — mood entries, mood analytics, and the tag catalog.
|
|
* Part of the centralized factory; aggregated in `./index.ts`.
|
|
*/
|
|
export const moodKeys = {
|
|
moodEntries: () => ["mood-entries"] as const,
|
|
|
|
/**
|
|
* v1.15.13 — the mood management-list read with its filter + sort +
|
|
* pagination state baked into the key, mirroring `measurementsList`.
|
|
* Rides under the `["mood-entries"]` prefix so `moodDependentKeys`
|
|
* (and a bulk-delete invalidation) reaches every slot.
|
|
*/
|
|
moodEntriesList: (params: {
|
|
mood: string | undefined;
|
|
source: string | undefined;
|
|
from: string | undefined;
|
|
to: string | undefined;
|
|
page: number;
|
|
sortBy: string;
|
|
sortDir: string;
|
|
}) =>
|
|
[
|
|
"mood-entries",
|
|
"list",
|
|
params.mood ?? null,
|
|
params.source ?? null,
|
|
params.from ?? null,
|
|
params.to ?? null,
|
|
params.page,
|
|
params.sortBy,
|
|
params.sortDir,
|
|
] as const,
|
|
|
|
/**
|
|
* v1.34.3 — every mood entry logged on ONE local day, read by the
|
|
* workout detail page's day context. Rides under the `["mood-entries"]`
|
|
* prefix so `moodDependentKeys` reaches it on a mood write, and carries
|
|
* its own `"day"` scope segment so it can never share a slot with
|
|
* `moodEntriesList` — same key with a different response shape silently
|
|
* poisons the cache.
|
|
*/
|
|
moodEntriesDay: (date: string) => ["mood-entries", "day", date] as const,
|
|
|
|
moodAnalytics: () => ["mood-analytics"] as const,
|
|
/**
|
|
* v1.8.5 — pre-computed mood-insights aggregates (heatmap, distribution,
|
|
* weekday, tag breakdown, cross-metric correlations) for the Mood
|
|
* Insights page. Read-only; invalidated on a mood write through the
|
|
* `moodDependentKeys` fan-out in `./index.ts`.
|
|
*/
|
|
moodInsights: () => ["mood-insights"] as const,
|
|
/**
|
|
* v1.8.5 — structured mood-tag taxonomy catalog (global reference
|
|
* data, identical for every user). Read by the mood-logging form's
|
|
* tag-category capture surface. Not invalidated on a mood write — the
|
|
* catalog only changes on a migration / admin edit, so a long
|
|
* `staleTime` is fine.
|
|
*/
|
|
moodTagCatalog: () => ["mood-tag-catalog"] as const,
|
|
/**
|
|
* v1.17 — the tag-MANAGEMENT read (`/api/mood/tags?include=
|
|
* hidden,archived,usage`). Rides under the `["mood-tag-catalog"]`
|
|
* prefix so one `invalidateQueries({ queryKey: ["mood-tag-catalog"] })`
|
|
* after any management mutation refreshes both this read and the
|
|
* picker read above (same trick as `moodEntriesList` under
|
|
* `["mood-entries"]`). The scope segment keeps the two queryFn shapes
|
|
* on different keys — same-key/different-shape silently poisons the
|
|
* cache.
|
|
*/
|
|
moodTagManage: () => ["mood-tag-catalog", "manage"] as const,
|
|
/**
|
|
* v1.17 — the per-user picker layout blob (`/api/mood/tags/layout`):
|
|
* group order + per-group tag placement. Its own root key — layout
|
|
* writes invalidate it alongside the catalog prefix.
|
|
*/
|
|
moodTagLayout: () => ["mood-tag-layout"] as const,
|
|
};
|