diff --git a/surfsense_web/atoms/permissions/permissions-query.atoms.ts b/surfsense_web/atoms/permissions/permissions-query.atoms.ts new file mode 100644 index 000000000..335ddd77d --- /dev/null +++ b/surfsense_web/atoms/permissions/permissions-query.atoms.ts @@ -0,0 +1,13 @@ +import { atomWithQuery } from "jotai-tanstack-query"; +import { permissionsApiService } from "@/lib/apis/permissions-api.service"; +import { cacheKeys } from "@/lib/query-client/cache-keys"; + +export const permissionsAtom = atomWithQuery(() => { + return { + queryKey: cacheKeys.permissions.all(), + staleTime: 10 * 60 * 1000, // 10 minutes + queryFn: async () => { + return permissionsApiService.getPermissions(); + }, + }; +}); diff --git a/surfsense_web/lib/query-client/cache-keys.ts b/surfsense_web/lib/query-client/cache-keys.ts index eb2c4972a..28e9396c9 100644 --- a/surfsense_web/lib/query-client/cache-keys.ts +++ b/surfsense_web/lib/query-client/cache-keys.ts @@ -3,6 +3,7 @@ import type { GetDocumentsRequest } from "@/contracts/types/document.types"; import type { GetLLMConfigsRequest } from "@/contracts/types/llm-config.types"; import type { GetPodcastsRequest } from "@/contracts/types/podcast.types"; import type { GetSearchSpacesRequest } from "@/contracts/types/search-space.types"; +import type { GetRolesRequest } from "@/contracts/types/roles.types"; export const cacheKeys = { chats: { @@ -44,4 +45,4 @@ export const cacheKeys = { user: { current: () => ["user", "me"] as const, }, -}; \ No newline at end of file +};