From f3b0ee51d5fb505c852c7378ba85776d15e22b86 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 21 Jun 2024 22:22:24 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=87=8D=E5=BB=BA=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E6=97=B6=E6=B8=85=E7=A9=BA=20scroll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/dialog/processSystem.ts | 12 +++++++++++- app/src/layout/dock/Files.ts | 3 ++- app/src/mobile/dock/MobileFiles.ts | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 5895356ae..95a9f47c7 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -278,11 +278,21 @@ export const transactionError = () => { /// #endif }); btnsElement[1].addEventListener("click", () => { - fetchPost("/api/filetree/refreshFiletree", {}); + refreshFileTree(); dialog.destroy(); }); }; +export const refreshFileTree = (cb?:() => void) => { + window.siyuan.storage[Constants.LOCAL_FILEPOSITION] = {}; + setStorageVal(Constants.LOCAL_FILEPOSITION, window.siyuan.storage[Constants.LOCAL_FILEPOSITION]); + fetchPost("/api/filetree/refreshFiletree", {}, () => { + if (cb) { + cb() + } + }); +} + let statusTimeout: number; export const progressStatus = (data: IWebSocketData) => { const statusElement = document.querySelector("#status") as HTMLElement; diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts index 699e5eaff..9e311c14e 100644 --- a/app/src/layout/dock/Files.ts +++ b/app/src/layout/dock/Files.ts @@ -19,6 +19,7 @@ import {openFileById} from "../../editor/util"; import {hasClosestByAttribute, hasClosestByTag, hasTopClosestByTag} from "../../protyle/util/hasClosest"; import {isTouchDevice} from "../../util/functions"; import {App} from "../../index"; +import {refreshFileTree} from "../../dialog/processSystem"; export class Files extends Model { public element: HTMLElement; @@ -1074,7 +1075,7 @@ aria-label="${escapeHtml(ariaLabel)}">${getDisplayName(item.name, true, true)} { if (!this.element.getAttribute("disabled")) { this.element.setAttribute("disabled", "disabled"); - fetchPost("/api/filetree/refreshFiletree", {}, () => { + refreshFileTree(() => { this.element.removeAttribute("disabled"); this.init(false); }); diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts index 5b658165d..2b7f8e3eb 100644 --- a/app/src/mobile/dock/MobileFiles.ts +++ b/app/src/mobile/dock/MobileFiles.ts @@ -14,6 +14,7 @@ import {confirmDialog} from "../../dialog/confirmDialog"; import {newFile} from "../../util/newFile"; import {MenuItem} from "../../menus/Menu"; import {App} from "../../index"; +import {refreshFileTree} from "../../dialog/processSystem"; export class MobileFiles extends Model { public element: HTMLElement; @@ -113,7 +114,7 @@ export class MobileFiles extends Model { Array.from(this.element.children).forEach(item => { notebooks.push(item.getAttribute("data-url")); }); - fetchPost("/api/filetree/refreshFiletree", {}, () => { + refreshFileTree(() => { target.removeAttribute("disabled"); this.init(false); });