mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
- Updated chat query to include ordering by creation date for better organization. - Improved optimistic updates in chat deletion and creation mutations to ensure UI consistency. - Invalidate chat queries after mutations to refresh sidebar and components effectively. - Adjusted cache key structure for chat queries to include additional parameters for better cache management.
71 lines
3 KiB
TypeScript
71 lines
3 KiB
TypeScript
import type { GetChatsRequest } from "@/contracts/types/chat.types";
|
|
import type { GetDocumentsRequest } from "@/contracts/types/document.types";
|
|
import type { GetLLMConfigsRequest } from "@/contracts/types/llm-config.types";
|
|
import type { GetMembersRequest } from "@/contracts/types/members.types";
|
|
import type { GetPodcastsRequest } from "@/contracts/types/podcast.types";
|
|
import type { GetRolesRequest } from "@/contracts/types/roles.types";
|
|
import type { GetSearchSpacesRequest } from "@/contracts/types/search-space.types";
|
|
|
|
export const cacheKeys = {
|
|
chats: {
|
|
activeChat: (chatId: string) => ["active-chat", chatId] as const,
|
|
globalQueryParams: (queries: GetChatsRequest["queryParams"]) =>
|
|
[
|
|
"chats",
|
|
queries?.search_space_id,
|
|
queries?.limit,
|
|
queries?.skip,
|
|
queries?.page,
|
|
queries?.page_size,
|
|
] as const,
|
|
},
|
|
podcasts: {
|
|
globalQueryParams: (queries: GetPodcastsRequest["queryParams"]) =>
|
|
["podcasts", ...(queries ? Object.values(queries) : [])] as const,
|
|
},
|
|
documents: {
|
|
globalQueryParams: (queries: GetDocumentsRequest["queryParams"]) =>
|
|
["documents", ...(queries ? Object.values(queries) : [])] as const,
|
|
withQueryParams: (queries: GetDocumentsRequest["queryParams"]) =>
|
|
["documents-with-queries", ...(queries ? Object.values(queries) : [])] as const,
|
|
document: (documentId: string) => ["document", documentId] as const,
|
|
typeCounts: (searchSpaceId?: string) => ["documents", "type-counts", searchSpaceId] as const,
|
|
byChunk: (chunkId: string) => ["documents", "by-chunk", chunkId] as const,
|
|
},
|
|
llmConfigs: {
|
|
global: () => ["llm-configs", "global"] as const,
|
|
all: (searchSpaceId: string) => ["llm-configs", searchSpaceId] as const,
|
|
withQueryParams: (queries: GetLLMConfigsRequest["queryParams"]) =>
|
|
["llm-configs", ...(queries ? Object.values(queries) : [])] as const,
|
|
byId: (llmConfigId: string) => ["llm-config", llmConfigId] as const,
|
|
preferences: (searchSpaceId: string) => ["llm-preferences", searchSpaceId] as const,
|
|
},
|
|
auth: {
|
|
user: ["auth", "user"] as const,
|
|
},
|
|
searchSpaces: {
|
|
all: ["search-spaces"] as const,
|
|
withQueryParams: (queries: GetSearchSpacesRequest["queryParams"]) =>
|
|
["search-spaces", ...(queries ? Object.values(queries) : [])] as const,
|
|
detail: (searchSpaceId: string) => ["search-spaces", searchSpaceId] as const,
|
|
communityPrompts: ["search-spaces", "community-prompts"] as const,
|
|
},
|
|
user: {
|
|
current: () => ["user", "me"] as const,
|
|
},
|
|
roles: {
|
|
all: (searchSpaceId: string) => ["roles", searchSpaceId] as const,
|
|
byId: (searchSpaceId: string, roleId: string) => ["roles", searchSpaceId, roleId] as const,
|
|
},
|
|
permissions: {
|
|
all: () => ["permissions"] as const,
|
|
},
|
|
members: {
|
|
all: (searchSpaceId: string) => ["members", searchSpaceId] as const,
|
|
myAccess: (searchSpaceId: string) => ["members", "my-access", searchSpaceId] as const,
|
|
},
|
|
invites: {
|
|
all: (searchSpaceId: string) => ["invites", searchSpaceId] as const,
|
|
info: (inviteCode: string) => ["invites", "info", inviteCode] as const,
|
|
},
|
|
};
|