mirror of
https://github.com/docmost/docmost
synced 2025-03-28 21:13:28 +00:00
fix wrong tree sync bug (#514)
This commit is contained in:
parent
f178e6654f
commit
311d81bc71
@ -191,7 +191,7 @@ export default function SpaceTree({ spaceId, readOnly }: SpaceTreeProps) {
|
||||
<div ref={mergedRef} className={classes.treeContainer}>
|
||||
{rootElement.current && (
|
||||
<Tree
|
||||
data={data}
|
||||
data={data.filter((node) => node?.spaceId === spaceId)}
|
||||
disableDrag={readOnly}
|
||||
disableDrop={readOnly}
|
||||
disableEdit={readOnly}
|
||||
|
@ -46,30 +46,34 @@ export const useTreeSocket = () => {
|
||||
break;
|
||||
case 'moveTreeNode':
|
||||
// move node
|
||||
treeApi.move({
|
||||
id: event.payload.id,
|
||||
parentId: event.payload.parentId,
|
||||
index: event.payload.index
|
||||
});
|
||||
if (treeApi.find(event.payload.id)) {
|
||||
treeApi.move({
|
||||
id: event.payload.id,
|
||||
parentId: event.payload.parentId,
|
||||
index: event.payload.index
|
||||
});
|
||||
|
||||
// update node position
|
||||
treeApi.update({
|
||||
id: event.payload.id,
|
||||
changes: {
|
||||
position: event.payload.position,
|
||||
}
|
||||
});
|
||||
// update node position
|
||||
treeApi.update({
|
||||
id: event.payload.id,
|
||||
changes: {
|
||||
position: event.payload.position,
|
||||
}
|
||||
});
|
||||
|
||||
setTreeData(treeApi.data);
|
||||
setTreeData(treeApi.data);
|
||||
}
|
||||
|
||||
break;
|
||||
case "deleteTreeNode":
|
||||
treeApi.drop({ id: event.payload.node.id });
|
||||
setTreeData(treeApi.data);
|
||||
if (treeApi.find(event.payload.node.id)){
|
||||
treeApi.drop({ id: event.payload.node.id });
|
||||
setTreeData(treeApi.data);
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['pages', event.payload.node.slugId].filter(Boolean),
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['pages', event.payload.node.slugId].filter(Boolean),
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user