mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
feat(search-spaces): add communityPromptsAtom and remove obvious comments
This commit is contained in:
parent
b4874111e2
commit
fc08f721b0
1 changed files with 11 additions and 3 deletions
|
|
@ -4,20 +4,18 @@ import type { GetSearchSpacesRequest } from "@/contracts/types/search-space.type
|
|||
import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
||||
// Atom to store current query params for search spaces
|
||||
export const searchSpacesQueryParamsAtom = atom<GetSearchSpacesRequest["queryParams"]>({
|
||||
skip: 0,
|
||||
limit: 10,
|
||||
owned_only: false,
|
||||
});
|
||||
|
||||
// Query atom to fetch search spaces with query params
|
||||
export const searchSpacesAtom = atomWithQuery((get) => {
|
||||
const queryParams = get(searchSpacesQueryParamsAtom);
|
||||
|
||||
return {
|
||||
queryKey: cacheKeys.searchSpaces.withQueryParams(queryParams),
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
staleTime: 5 * 60 * 1000,
|
||||
queryFn: async () => {
|
||||
return searchSpacesApiService.getSearchSpaces({
|
||||
queryParams,
|
||||
|
|
@ -25,3 +23,13 @@ export const searchSpacesAtom = atomWithQuery((get) => {
|
|||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const communityPromptsAtom = atomWithQuery(() => {
|
||||
return {
|
||||
queryKey: cacheKeys.searchSpaces.communityPrompts,
|
||||
staleTime: 30 * 60 * 1000,
|
||||
queryFn: async () => {
|
||||
return searchSpacesApiService.getCommunityPrompts();
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue