mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
perf(dashboard): seed the mood chart's series from the snapshot
The dashboard snapshot carries the mood tile's series from the same engine `/api/mood/analytics` answers from, and the snapshot already seeds the widget layout, but nothing seeded the mood analytics cell the mood chart reads, so every dashboard open with the mood chart asked for the series again. Both seed points, the server render and the client snapshot read, now fill that cell too, under the same rule as the layout: only an empty cell, and only when the tile has readings, the one case where its summary is the route's.
This commit is contained in:
1 parent
ea6e94adcf
commit
b970ea7468
3 files changed
+68
No files matched your search
@@ -102,6 +102,19 @@ export default async function DashboardPage() {
|
||||
const queryClient = new QueryClient();
|
||||
queryClient.setQueryData(queryKeys.dashboardSnapshot(locale), wireBody);
|
||||
queryClient.setQueryData(queryKeys.dashboardWidgets(), wireBody.layout);
|
||||
// The mood chart's series rides the mood tile (same engine as
|
||||
// `/api/mood/analytics`); seeded with readings only, where the tile's
|
||||
// summary is the route's.
|
||||
const mood = (
|
||||
wireBody.tiles as
|
||||
{ mood?: { entries: unknown[]; summary: unknown } } | undefined
|
||||
)?.mood;
|
||||
if (mood?.summary && mood.entries.length > 0) {
|
||||
queryClient.setQueryData(queryKeys.moodAnalytics(), {
|
||||
entries: mood.entries,
|
||||
summary: mood.summary,
|
||||
});
|
||||
}
|
||||
|
||||
// Above-the-fold prefetch runs ONLY in snapshot mode: legacy mode derives
|
||||
// its chart-type list from analytics queries the RSC did not run, so there
|
||||
|
||||
Reference in new issue
Block a user