From 8a6ba2b2d0840e725a625efb5d59132aefae6118 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 23 Nov 2024 00:11:18 +0800 Subject: [PATCH] :bug: https://github.com/siyuan-note/siyuan/issues/13230 --- app/src/layout/dock/Backlink.ts | 4 ++-- app/src/protyle/index.ts | 36 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts index 025b81383..3d73f49ac 100644 --- a/app/src/layout/dock/Backlink.ts +++ b/app/src/layout/dock/Backlink.ts @@ -462,10 +462,10 @@ export class Backlink extends Model { } public refresh() { - if (!this.blockId) { + const element = this.element.querySelector('.block__icon[data-type="refresh"] svg'); + if (!this.blockId || element.classList.contains("fn__rotate")) { return; } - const element = this.element.querySelector('.block__icon[data-type="refresh"] svg'); element.classList.add("fn__rotate"); fetchPost("/api/ref/refreshBacklink", { id: this.blockId, diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 730ced09f..0671653eb 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -126,24 +126,24 @@ export class Protyle { } break; case "transactions": - if (options.backlinkData) { - getAllModels().backlink.find(item => { - if (item.element.contains(this.protyle.element)) { - item.refresh(); - return true; - } - }); - } else { - data.data[0].doOperations.forEach((item: IOperation) => { - if (!this.protyle.preview.element.classList.contains("fn__none") && - item.action !== "updateAttrs" // 预览模式下点击只读 - ) { - this.protyle.preview.render(this.protyle); - } else { - onTransaction(this.protyle, item, false); - } - }); - } + data.data[0].doOperations.find((item: IOperation) => { + if (!this.protyle.preview.element.classList.contains("fn__none") && + item.action !== "updateAttrs" // 预览模式下点击只读 + ) { + this.protyle.preview.render(this.protyle); + } else if (options.backlinkData && ["delete", "move"].includes(item.action)) { + // 只对特定情况刷新,否则展开、编辑等操作刷新会频繁 + getAllModels().backlink.find(backlinkItem => { + if (backlinkItem.element.contains(this.protyle.element)) { + backlinkItem.refresh(); + return true; + } + }); + return true; + } else { + onTransaction(this.protyle, item, false); + } + }); break; case "readonly": window.siyuan.config.editor.readOnly = data.data;