mirror of
https://github.com/docmost/docmost.git
synced 2025-11-16 23:31:12 +10:00
fix: sidebar list when changing workspace (#1150)
* init * navigate in overview if current page is in deleted node * fix: implement pagination in sidebar-pages queries * fix: appendNodeChildren() Preserve deeper children if they exist and remove node if deleted
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { SpaceTreeNode } from "@/features/page/tree/types.ts";
|
||||
import { IPage } from "@/features/page/types/page.types";
|
||||
|
||||
export type InvalidateEvent = {
|
||||
operation: "invalidate";
|
||||
@ -17,7 +18,7 @@ export type UpdateEvent = {
|
||||
spaceId: string;
|
||||
entity: Array<string>;
|
||||
id: string;
|
||||
payload: Partial<any>;
|
||||
payload: Partial<IPage>;
|
||||
};
|
||||
|
||||
export type DeleteEvent = {
|
||||
@ -25,7 +26,7 @@ export type DeleteEvent = {
|
||||
spaceId: string;
|
||||
entity: Array<string>;
|
||||
id: string;
|
||||
payload?: Partial<any>;
|
||||
payload?: Partial<IPage>;
|
||||
};
|
||||
|
||||
export type AddTreeNodeEvent = {
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import React from "react";
|
||||
import { socketAtom } from "@/features/websocket/atoms/socket-atom.ts";
|
||||
import { useAtom } from "jotai";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { InfiniteData, useQueryClient } from "@tanstack/react-query";
|
||||
import { WebSocketEvent } from "@/features/websocket/types";
|
||||
import { IPage } from "../page/types/page.types";
|
||||
import { IPagination } from "@/lib/types";
|
||||
import { invalidateOnCreatePage, invalidateOnDeletePage, invalidateOnMovePage, invalidateOnUpdatePage } from "../page/queries/page-query";
|
||||
import { RQ_KEY } from "../comment/queries/comment-query";
|
||||
|
||||
export const useQuerySubscription = () => {
|
||||
@ -27,6 +30,16 @@ export const useQuerySubscription = () => {
|
||||
queryKey: RQ_KEY(data.pageId),
|
||||
});
|
||||
break;
|
||||
case "addTreeNode":
|
||||
invalidateOnCreatePage(data.payload.data);
|
||||
break;
|
||||
case "moveTreeNode":
|
||||
invalidateOnMovePage();
|
||||
break;
|
||||
case "deleteTreeNode":
|
||||
const pageId = data.payload.node.id;
|
||||
invalidateOnDeletePage(pageId);
|
||||
break;
|
||||
case "updateOne":
|
||||
entity = data.entity[0];
|
||||
if (entity === "pages") {
|
||||
@ -43,7 +56,11 @@ export const useQuerySubscription = () => {
|
||||
...data.payload,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (entity === "pages") {
|
||||
invalidateOnUpdatePage(data.spaceId, data.payload.parentPageId, data.id, data.payload.title, data.payload.icon);
|
||||
}
|
||||
|
||||
/*
|
||||
queryClient.setQueriesData(
|
||||
{ queryKey: [data.entity, data.id] },
|
||||
@ -55,7 +72,7 @@ export const useQuerySubscription = () => {
|
||||
: update(oldData as Record<string, unknown>);
|
||||
},
|
||||
);
|
||||
*/
|
||||
*/
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user