mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-07 14:52:39 +02:00
feat: add snapshots cache key and query atom
This commit is contained in:
parent
47b7befc55
commit
e62e4faaa5
2 changed files with 25 additions and 0 deletions
22
surfsense_web/atoms/snapshots/snapshots-query.atoms.ts
Normal file
22
surfsense_web/atoms/snapshots/snapshots-query.atoms.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { atomWithQuery } from "jotai-tanstack-query";
|
||||
import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||
import { chatThreadsApiService } from "@/lib/apis/chat-threads-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
||||
export const searchSpaceSnapshotsAtom = atomWithQuery((get) => {
|
||||
const searchSpaceId = get(activeSearchSpaceIdAtom);
|
||||
|
||||
return {
|
||||
queryKey: cacheKeys.snapshots.bySearchSpace(Number(searchSpaceId) || 0),
|
||||
enabled: !!searchSpaceId,
|
||||
staleTime: 5 * 60 * 1000,
|
||||
queryFn: async () => {
|
||||
if (!searchSpaceId) {
|
||||
return { snapshots: [] };
|
||||
}
|
||||
return chatThreadsApiService.listSearchSpaceSnapshots({
|
||||
search_space_id: Number(searchSpaceId),
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue