@phygitallabs/tapquest-core 6.4.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phygitallabs/tapquest-core",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -95,4 +95,6 @@ export {
95
95
  getLocationIdsFromAchievementRule,
96
96
  getActionsFromAchievementRule,
97
97
  isAchievementCompleted
98
- }
98
+ }
99
+
100
+ export { useClearAchievementProgressCache } from './useClearAchievementProgressCache';
@@ -0,0 +1,40 @@
1
+ import { useQueryClient } from "@tanstack/react-query";
2
+ import { useCallback } from "react";
3
+
4
+ export function useClearAchievementProgressCache() {
5
+ const queryClient = useQueryClient();
6
+
7
+ const clearCache = useCallback(
8
+ (options?: {
9
+ refetchActive?: boolean;
10
+ refetchInactive?: boolean;
11
+ }) => {
12
+ const { refetchActive = true, refetchInactive = false } = options || {};
13
+
14
+ // Clear all achievement progress related queries
15
+ // Query keys from packages/achievement/src/hooks/useAchievement.ts
16
+ const queryKeyPatterns = [
17
+ ["deviceUidAchievementProgressMany"], // Device UID progress (line 69)
18
+ ["achievementProgressMany"], // All achievements (line 39)
19
+ ];
20
+
21
+ queryKeyPatterns.forEach((queryKey) => {
22
+ // Invalidate the queries to mark them as stale
23
+ queryClient.invalidateQueries({
24
+ queryKey,
25
+ refetchType: refetchActive
26
+ ? refetchInactive
27
+ ? "all"
28
+ : "active"
29
+ : "none",
30
+ });
31
+ });
32
+
33
+ console.log("🔄 Achievement progress cache cleared");
34
+ },
35
+ [queryClient]
36
+ );
37
+ return {
38
+ clearCache,
39
+ };
40
+ }
@@ -4,17 +4,17 @@ import {
4
4
  GetManyAchievementProgressByDeviceParams,
5
5
  } from "@phygitallabs/api-core";
6
6
 
7
- import { useManyAchievementProgress as useManyAchievementProgressCore } from "@phygitallabs/achievement";
8
7
  import { useManyAchievementProgressByDevice as useManyAchievementProgressByDeviceCore } from "@phygitallabs/api-core";
9
-
10
8
  // Core react query hooks
11
9
  import {
10
+ useManyAchievementProgress as useManyAchievementProgressCore,
12
11
  useAchievementProgress,
13
12
  useManyAchievements,
14
13
  useUserAchievementAction,
15
- useManyChildrenAchievements,
16
14
  useOneAchievement,
17
15
  useManyAchievementsRewardModels,
16
+ useManyAchievementsByLocation,
17
+ useManyChildrenAchievements
18
18
  } from "@phygitallabs/achievement";
19
19
 
20
20
  import { isAchievementCompleted, convertSnakeToCamel } from "../helpers";
@@ -24,8 +24,10 @@ export {
24
24
  useManyAchievements,
25
25
  useUserAchievementAction,
26
26
  useManyChildrenAchievements,
27
+ useManyAchievementProgressCore,
27
28
  useOneAchievement,
28
29
  useManyAchievementsRewardModels,
30
+ useManyAchievementsByLocation
29
31
  }
30
32
 
31
33
  // Customize react query hooks