diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index 67c542e27..19fa43f4c 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -18,6 +18,8 @@ import {redirectToCheckAuth} from "../util/pathName"; import {getAllModels} from "../layout/getAll"; import {reloadProtyle} from "../protyle/util/reload"; import {Tab} from "../layout/Tab"; +import {setEmpty} from "../mobile/util/setEmpty"; +import {hideElements} from "../protyle/ui/hideElements"; const updateTitle = (rootID: string, tab: Tab) => { @@ -27,7 +29,30 @@ const updateTitle = (rootID: string, tab: Tab) => { tab.updateTitle(response.data.name); }); }; + export const reloadSync = (data: { upsertRootIDs: string[], removeRootIDs: string[] }) => { + /// #if MOBILE + if (window.siyuan.mobile.popEditor) { + if (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) { + hideElements(["dialog"]); + } else { + reloadProtyle(window.siyuan.mobile.popEditor.protyle); + } + } + if (window.siyuan.mobile.editor) { + if (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) { + setEmpty(); + } else { + reloadProtyle(window.siyuan.mobile.editor.protyle); + fetchPost("/api/block/getDocInfo", { + id: window.siyuan.mobile.editor.protyle.block.rootID + }, (response) => { + (document.getElementById("toolbarName") as HTMLInputElement).value = response.data.rootTitle === "Untitled" ? "" : response.data.rootTitle; + }); + } + } + window.siyuan.mobile.files.init(false); + /// #else const allModels = getAllModels(); allModels.editor.forEach(item => { if (data.upsertRootIDs.includes(item.editor.protyle.block.rootID)) { @@ -84,6 +109,7 @@ export const reloadSync = (data: { upsertRootIDs: string[], removeRootIDs: strin allModels.search.forEach(item => { item.parent.panelElement.querySelector("#searchInput").dispatchEvent(new CustomEvent("input")); }); + /// #endif }; export const lockScreen = () => { diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.ts index d83b6ccdb..55e783ed7 100644 --- a/app/src/mobile/dock/MobileFiles.ts +++ b/app/src/mobile/dock/MobileFiles.ts @@ -266,7 +266,7 @@ export class MobileFiles extends Model { } } - private init(init = true) { + public init(init = true) { let html = ""; let closeHtml = ""; window.siyuan.notebooks.forEach((item) => { diff --git a/app/src/mobile/util/onMessage.ts b/app/src/mobile/util/onMessage.ts index 57c3b939b..73554fede 100644 --- a/app/src/mobile/util/onMessage.ts +++ b/app/src/mobile/util/onMessage.ts @@ -1,5 +1,5 @@ import {openMobileFileById} from "../editor"; -import {processSync, progressLoading, progressStatus, transactionError} from "../../dialog/processSystem"; +import {processSync, progressLoading, progressStatus, reloadSync, transactionError} from "../../dialog/processSystem"; import {Constants} from "../../constants"; const processReadonly = () => { @@ -17,6 +17,9 @@ const processReadonly = () => { export const onMessage = (data: IWebSocketData) => { if (data) { switch (data.cmd) { + case "syncMergeResult": + reloadSync(data.data); + break; case "readonly": window.siyuan.config.editor.readOnly = data.data; processReadonly(); diff --git a/app/src/protyle/wysiwyg/turnIntoList.ts b/app/src/protyle/wysiwyg/turnIntoList.ts index 48510c366..c11d9ecba 100644 --- a/app/src/protyle/wysiwyg/turnIntoList.ts +++ b/app/src/protyle/wysiwyg/turnIntoList.ts @@ -64,7 +64,6 @@ export const turnIntoTaskList = (protyle: IProtyle, type: string, blockElement: return false } - export const headingTurnIntoList = (protyle: IProtyle, type: string, blockElement: HTMLElement, editElement: HTMLElement) => { if (type !== "NodeHeading" && ["* ", "- "].includes(editElement.innerHTML.substring(0, 2))) { const id = blockElement.getAttribute("data-node-id") diff --git a/app/src/window/index.ts b/app/src/window/index.ts index 809a1f324..ee0e22c94 100644 --- a/app/src/window/index.ts +++ b/app/src/window/index.ts @@ -11,7 +11,7 @@ import {openFileById} from "../editor/util"; import { processSync, progressBackgroundTask, progressLoading, - progressStatus, + progressStatus, reloadSync, setTitle, transactionError } from "../dialog/processSystem"; @@ -42,6 +42,9 @@ class App { msgCallback: (data) => { if (data) { switch (data.cmd) { + case "syncMergeResult": + reloadSync(data.data); + break; case "progress": progressLoading(data); break;