mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
fix(workouts): refresh the Insights Workouts pill after a workout write
The tab strip shows the Workouts pill from the presence read, which stays fresh for five minutes and was not part of the workout write's invalidation. After the first manual workout, or after deleting the last one, the pill stayed missing or stayed on for up to five minutes.
This commit is contained in:
1 parent
6f8a342edf
commit
d430981caa
2 files changed
+18
-1
No files matched your search
@@ -11,6 +11,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { invalidateSymptomReads } from "@/components/symptoms/use-symptoms";
|
||||
import {
|
||||
allergyDependentKeys,
|
||||
invalidateKeys,
|
||||
cycleDependentKeys,
|
||||
documentDependentKeys,
|
||||
encounterDependentKeys,
|
||||
@@ -47,6 +48,20 @@ describe("record writes reach the day view and the timeline", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("a workout write marks the Insights presence read stale", async () => {
|
||||
// The Workouts pill appears with the first workout and goes with the
|
||||
// last; the presence read otherwise stays fresh for five minutes.
|
||||
const client = new QueryClient();
|
||||
client.setQueryData(queryKeys.insightsPresence(), { hasWorkouts: false });
|
||||
|
||||
await invalidateKeys(client, workoutDependentKeys);
|
||||
|
||||
expect(
|
||||
client.getQueryState(queryKeys.insightsPresence())?.isInvalidated,
|
||||
).toBe(true);
|
||||
client.clear();
|
||||
});
|
||||
|
||||
it("a symptom write marks an open day and the timeline stale", async () => {
|
||||
const client = new QueryClient();
|
||||
const day = queryKeys.day("2026-11-10");
|
||||
|
||||
@@ -364,10 +364,12 @@ export const vaccinationDependentKeys = [
|
||||
* digest names a workout that just arrived and the write evicts the server's
|
||||
* daily caches, so the daily reads ride along; pair call sites with
|
||||
* `refetchInactiveDailyReads`, because both are unmounted wherever the form
|
||||
* opens outside the dashboard.
|
||||
* opens outside the dashboard. The Insights tab strip shows the Workouts
|
||||
* pill from the presence read.
|
||||
*/
|
||||
export const workoutDependentKeys = [
|
||||
queryKeys.workouts(),
|
||||
queryKeys.insightsPresence(),
|
||||
queryKeys.dashboardSnapshot(),
|
||||
queryKeys.dailyDigest(),
|
||||
queryKeys.dayRoot(),
|
||||
|
||||
Reference in new issue
Block a user