From c437f8df9e529ea49db0099b10e6d41722fea5b0 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 30 Oct 2023 00:22:37 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9544 --- app/src/mobile/util/setEmpty.ts | 24 ++++-------------------- app/src/util/newFile.ts | 5 +++++ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/app/src/mobile/util/setEmpty.ts b/app/src/mobile/util/setEmpty.ts index de535073c..942a478b6 100644 --- a/app/src/mobile/util/setEmpty.ts +++ b/app/src/mobile/util/setEmpty.ts @@ -51,26 +51,10 @@ export const setEmpty = (app: App) => { event.preventDefault(); break; } else if (target.id === "emptyNewFile") { - if (window.siyuan.mobile.editor) { - newFile({ - app, - notebookId: window.siyuan.mobile.editor.protyle.notebookId, - currentPath: window.siyuan.mobile.editor.protyle.path, - useSavePath: true - }); - } else { - window.siyuan.notebooks.find(item => { - if (!item.closed) { - newFile({ - app, - notebookId: item.id, - currentPath: "/", - useSavePath: true - }); - return true; - } - }); - } + newFile({ + app, + useSavePath: true + }); event.stopPropagation(); event.preventDefault(); break; diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts index a45a9e060..c5913d455 100644 --- a/app/src/util/newFile.ts +++ b/app/src/util/newFile.ts @@ -53,6 +53,11 @@ export const getNewFilePath = (useSavePath: boolean) => { /// #else if (window.siyuan.mobile.editor) { notebookId = window.siyuan.mobile.editor.protyle.notebookId; + if (useSavePath) { + currentPath = window.siyuan.mobile.editor.protyle.path; + } else { + currentPath = pathPosix().dirname(window.siyuan.mobile.editor.protyle.path); + } } /// #endif if (!notebookId) {