Vanessa 2024-06-24 21:46:20 +08:00
parent 4f6f4770eb
commit 4f4d41ebb4
3 changed files with 16 additions and 6 deletions

View file

@ -35,7 +35,14 @@ const updateTitle = (rootID: string, tab: Tab, protyle?: IProtyle) => {
});
};
export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRootIDs: string[] }, hideMsg = true) => {
export const reloadSync = (
app: App,
data: { upsertRootIDs: string[], removeRootIDs: string[] },
hideMsg = true,
// 同步的时候需要更新只读状态 https://github.com/siyuan-note/siyuan/issues/11517
// 调整大纲的时候需要使用现有状态 https://github.com/siyuan-note/siyuan/issues/11808
updateReadonly = true
) => {
if (hideMsg) {
hideMessage();
}
@ -44,14 +51,14 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRoot
if (data.removeRootIDs.includes(window.siyuan.mobile.popEditor.protyle.block.rootID)) {
hideElements(["dialog"]);
} else {
reloadProtyle(window.siyuan.mobile.popEditor.protyle, false);
reloadProtyle(window.siyuan.mobile.popEditor.protyle, false, updateReadonly);
}
}
if (window.siyuan.mobile.editor) {
if (data.removeRootIDs.includes(window.siyuan.mobile.editor.protyle.block.rootID)) {
setEmpty(app);
} else {
reloadProtyle(window.siyuan.mobile.editor.protyle, false);
reloadProtyle(window.siyuan.mobile.editor.protyle, false, updateReadonly);
fetchPost("/api/block/getDocInfo", {
id: window.siyuan.mobile.editor.protyle.block.rootID
}, (response) => {
@ -71,7 +78,7 @@ export const reloadSync = (app: App, data: { upsertRootIDs: string[], removeRoot
id: item.editor.protyle.block.rootID,
}, (response) => {
item.editor.protyle.wysiwyg.renderCustom(response.data.ial);
reloadProtyle(item.editor.protyle, false, true);
reloadProtyle(item.editor.protyle, false, updateReadonly);
updateTitle(item.editor.protyle.block.rootID, item.parent, item.editor.protyle);
});
} else if (data.removeRootIDs.includes(item.editor.protyle.block.rootID)) {
@ -283,7 +290,7 @@ export const transactionError = () => {
});
};
export const refreshFileTree = (cb?:() => void) => {
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", {}, () => {

View file

@ -72,7 +72,7 @@ export class App {
reloadSync(this, data.data);
break;
case "reloaddoc":
reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false);
reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false, false);
break;
case "readonly":
window.siyuan.config.editor.readOnly = data.data;

View file

@ -59,6 +59,9 @@ class App {
window.siyuan.emojis = response.data as IEmoji[];
});
break;
case "reloaddoc":
reloadSync(this, {upsertRootIDs: [data.data], removeRootIDs: []}, false, false);
break;
case "syncMergeResult":
reloadSync(this, data.data);
break;