mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
Issues Fixed - Missing pagination fields in API response schemas (page, page_size, has_more) - NOTE enum missing from frontend Zod schema - Missing fields in DocumentRead response construction (content_hash, updated_at) - BlockNote slash menu clipped by overflow-hidden CSS - Sidebar click conflicts - hidden action buttons intercepting clicks - Rewrote All Notes sidebar - replaced fragile custom portal with shadcn Sheet - Missing translation keys for new UI strings - Missing NOTE retrieval logic in researcher agent - Added search to All Notes sidebar - Removed frontend logging - was causing toasters on every page refresh - Added backend logging to document reindex Celery task
75 lines
2.3 KiB
TypeScript
75 lines
2.3 KiB
TypeScript
import { atomWithMutation } from "jotai-tanstack-query";
|
|
import { toast } from "sonner";
|
|
import type {
|
|
CreateSearchSpaceRequest,
|
|
DeleteSearchSpaceRequest,
|
|
UpdateSearchSpaceRequest,
|
|
} from "@/contracts/types/search-space.types";
|
|
import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
import { queryClient } from "@/lib/query-client/client";
|
|
import { activeSearchSpaceIdAtom } from "./search-space-query.atoms";
|
|
|
|
export const createSearchSpaceMutationAtom = atomWithMutation(() => {
|
|
return {
|
|
mutationKey: ["create-search-space"],
|
|
mutationFn: async (request: CreateSearchSpaceRequest) => {
|
|
return searchSpacesApiService.createSearchSpace(request);
|
|
},
|
|
|
|
onSuccess: () => {
|
|
toast.success("Search space created successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.searchSpaces.all,
|
|
});
|
|
},
|
|
};
|
|
});
|
|
|
|
export const updateSearchSpaceMutationAtom = atomWithMutation((get) => {
|
|
const activeSearchSpaceId = get(activeSearchSpaceIdAtom);
|
|
|
|
return {
|
|
mutationKey: ["update-search-space", activeSearchSpaceId],
|
|
enabled: !!activeSearchSpaceId,
|
|
mutationFn: async (request: UpdateSearchSpaceRequest) => {
|
|
return searchSpacesApiService.updateSearchSpace(request);
|
|
},
|
|
|
|
onSuccess: (_, request: UpdateSearchSpaceRequest) => {
|
|
toast.success("Search space updated successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.searchSpaces.all,
|
|
});
|
|
if (request.id) {
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.searchSpaces.detail(String(request.id)),
|
|
});
|
|
}
|
|
},
|
|
};
|
|
});
|
|
|
|
export const deleteSearchSpaceMutationAtom = atomWithMutation((get) => {
|
|
const activeSearchSpaceId = get(activeSearchSpaceIdAtom);
|
|
|
|
return {
|
|
mutationKey: ["delete-search-space", activeSearchSpaceId],
|
|
enabled: !!activeSearchSpaceId,
|
|
mutationFn: async (request: DeleteSearchSpaceRequest) => {
|
|
return searchSpacesApiService.deleteSearchSpace(request);
|
|
},
|
|
|
|
onSuccess: (_, request: DeleteSearchSpaceRequest) => {
|
|
toast.success("Search space deleted successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.searchSpaces.all,
|
|
});
|
|
if (request.id) {
|
|
queryClient.removeQueries({
|
|
queryKey: cacheKeys.searchSpaces.detail(String(request.id)),
|
|
});
|
|
}
|
|
},
|
|
};
|
|
});
|