eletrotupi / tcc/ commit / 507c97f

frontend: double check others insights invalidation rules

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 507c97f5ff722b353a218e5ce11526754af998a2
Parents: e0a65f8
2 file(s) changed
  • frontend/hooks/useMoodEntries.queries.ts +5 -0
  • frontend/hooks/useSleepRecord.queries.ts +6 -9
frontend/hooks/useMoodEntries.queries.ts
1 1
import {
2 2
  useQuery,
3 3
  useMutation,
4 4
  useQueryClient,
5 5
  useInfiniteQuery,
▸ 131 unchanged lines
137 137
      }
138 138
    },
139 139

140 140
    onSuccess: () => {
141 141
      queryClient.invalidateQueries({ queryKey: moodKeys.lists() });
142 +
      setTimeout(() => {
143 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("MOOD_TREND") });
144 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("ENERGY_SLEEP_CORRELATION") });
145 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("DAILY_ENERGY") });
146 +
      }, 2000);
142 147
    },
143 148
  });
144 149
};
frontend/hooks/useSleepRecord.queries.ts
1 1
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
2 2

3 3
import { apiClient, SleepRecord, SleepRecordPayload } from "@/lib/api";
4 4
import { insightKeys } from "./useInsights.queries";
5 5

▸ 65 unchanged lines
71 71
    onSuccess: () => {
72 72
      queryClient.invalidateQueries({ queryKey: sleepRecordKeys.lists() });
73 73

74 74
      // Invalidate insights, so we can force refresh
75 75
      setTimeout(() => {
76 -
        queryClient.invalidateQueries({
77 -
          queryKey: insightKeys.byType("DAILY_ENERGY"),
78 -
        });
79 -
        queryClient.invalidateQueries({
80 -
          queryKey: insightKeys.byType("MOOD_TREND"),
81 -
        });
82 -
        queryClient.invalidateQueries({
83 -
          queryKey: insightKeys.byType("ENERGY_SLEEP_CORRELATION"),
84 -
        });
76 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("ENERGY_SLEEP_CORRELATION") });
77 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("DAILY_SLEEP") });
85 78
      }, 2000);
86 79
    },
87 80
  });
88 81
};
89 82

▸ 22 unchanged lines
112 105
      }
113 106
    },
114 107

115 108
    onSuccess: () => {
116 109
      queryClient.invalidateQueries({ queryKey: sleepRecordKeys.lists() });
110 +
      setTimeout(() => {
111 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("ENERGY_SLEEP_CORRELATION") });
112 +
        queryClient.invalidateQueries({ queryKey: insightKeys.byType("DAILY_SLEEP") });
113 +
      }, 2000);
117 114
    },
118 115
  });
119 116
};