mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-19 18:45:15 +02:00
Merge pull request #1391 from guangyang1206/fix/log-mutations-invalidate-all-keys-1369
fix(web): invalidate all log cache keys on log mutations
This commit is contained in:
commit
7f66159af1
1 changed files with 4 additions and 15 deletions
|
|
@ -19,10 +19,8 @@ export const createLogMutationAtom = atomWithMutation((get) => {
|
||||||
enabled: !!searchSpaceId,
|
enabled: !!searchSpaceId,
|
||||||
mutationFn: async (request: CreateLogRequest) => logsApiService.createLog(request),
|
mutationFn: async (request: CreateLogRequest) => logsApiService.createLog(request),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: cacheKeys.logs.list(searchSpaceId ?? undefined) });
|
// Invalidate all log-related queries (list, summary, detail, withQueryParams)
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({ queryKey: ["logs"] });
|
||||||
queryKey: cacheKeys.logs.summary(searchSpaceId ?? undefined),
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -38,11 +36,7 @@ export const updateLogMutationAtom = atomWithMutation((get) => {
|
||||||
mutationFn: async ({ logId, data }: { logId: number; data: UpdateLogRequest }) =>
|
mutationFn: async ({ logId, data }: { logId: number; data: UpdateLogRequest }) =>
|
||||||
logsApiService.updateLog(logId, data),
|
logsApiService.updateLog(logId, data),
|
||||||
onSuccess: (_data, variables) => {
|
onSuccess: (_data, variables) => {
|
||||||
queryClient.invalidateQueries({ queryKey: cacheKeys.logs.detail(variables.logId) });
|
queryClient.invalidateQueries({ queryKey: ["logs"] });
|
||||||
queryClient.invalidateQueries({ queryKey: cacheKeys.logs.list(searchSpaceId ?? undefined) });
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: cacheKeys.logs.summary(searchSpaceId ?? undefined),
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -57,12 +51,7 @@ export const deleteLogMutationAtom = atomWithMutation((get) => {
|
||||||
enabled: !!searchSpaceId,
|
enabled: !!searchSpaceId,
|
||||||
mutationFn: async (request: DeleteLogRequest) => logsApiService.deleteLog(request),
|
mutationFn: async (request: DeleteLogRequest) => logsApiService.deleteLog(request),
|
||||||
onSuccess: (_data, request) => {
|
onSuccess: (_data, request) => {
|
||||||
queryClient.invalidateQueries({ queryKey: cacheKeys.logs.list(searchSpaceId ?? undefined) });
|
queryClient.invalidateQueries({ queryKey: ["logs"] });
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: cacheKeys.logs.summary(searchSpaceId ?? undefined),
|
|
||||||
});
|
|
||||||
if (request?.id)
|
|
||||||
queryClient.invalidateQueries({ queryKey: cacheKeys.logs.detail(request.id) });
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue