feat(search-spaces): add communityPromptsAtom and remove obvious comments

This commit is contained in:
CREDO23 2025-12-11 21:00:17 +00:00
parent b4874111e2
commit fc08f721b0

View file

@ -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();
},
};
});