mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
ce1503af85
* 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
20 lines
524 B
TypeScript
20 lines
524 B
TypeScript
import { atom } from "jotai";
|
|
import { SpaceTreeNode } from "@/features/page/tree/types";
|
|
import { appendNodeChildren } from "../utils";
|
|
|
|
export const treeDataAtom = atom<SpaceTreeNode[]>([]);
|
|
|
|
// Atom
|
|
export const appendNodeChildrenAtom = atom(
|
|
null,
|
|
(
|
|
get,
|
|
set,
|
|
{ parentId, children }: { parentId: string; children: SpaceTreeNode[] }
|
|
) => {
|
|
const currentTree = get(treeDataAtom);
|
|
const updatedTree = appendNodeChildren(currentTree, parentId, children);
|
|
set(treeDataAtom, updatedTree);
|
|
}
|
|
);
|