From 154cf897b3fbe07155b4edd2cec65a90a93006ef Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:45:01 +0500 Subject: [PATCH] web: fix move notebook dialog (#8214) * also use db.notebooks.parentId() Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- apps/web/src/dialogs/move-notebook-dialog.tsx | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/apps/web/src/dialogs/move-notebook-dialog.tsx b/apps/web/src/dialogs/move-notebook-dialog.tsx index 362463db6..50da24940 100644 --- a/apps/web/src/dialogs/move-notebook-dialog.tsx +++ b/apps/web/src/dialogs/move-notebook-dialog.tsx @@ -54,7 +54,7 @@ export const MoveNotebookDialog = DialogManager.register( useEffect(() => { (async function () { - const parentNotebookId = await getParentNotebookId(notebookId); + const parentNotebookId = await db.notebooks.parentId(notebookId); const selected = useSelectionStore.getState().selected[0]; if (!selected && parentNotebookId) { setSelected([{ id: parentNotebookId, new: false, op: "add" }]); @@ -140,8 +140,8 @@ export const MoveNotebookDialog = DialogManager.register( rootId={"root"} itemHeight={30} treeRef={treeRef} - getChildNodes={async (id, depth) => { - const parentNotebookId = await getParentNotebookId( + getChildNodes={async ({ id, depth }) => { + const parentNotebookId = await db.notebooks.parentId( notebookId ); const nodes: TreeNode[] = []; @@ -240,16 +240,3 @@ export const MoveNotebookDialog = DialogManager.register( ); } ); - -async function getParentNotebookId(notebookId: string) { - const relation = await db.relations - .to( - { - id: notebookId, - type: "notebook" - }, - "notebook" - ) - .get(); - return relation[0]?.fromId; -}