Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Refresh database panels after schema changes https://github.com/siyuan-note/siyuan/issues/18321

Daniel2f49504b352c
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index f940c85803..4b7d10e1f9 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -940,7 +940,13 @@ export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
action: "doUpdateUpdated",
id,
data: blockElement.getAttribute("updated")
- }]);
+ }], {
+ callback: () => {
+ if (protyle.databaseAttributePanel?.hasDatabase(avId)) {
+ protyle.databaseAttributePanel.refresh();
+ }
+ }
+ });
blockElement.setAttribute("updated", newUpdated);
nameElement.dataset.title = newData;
diff --git a/app/src/protyle/render/av/attributePanel.ts b/app/src/protyle/render/av/attributePanel.ts
index 346f531073..613790ab92 100644
--- a/app/src/protyle/render/av/attributePanel.ts
+++ b/app/src/protyle/render/av/attributePanel.ts
@@ -4,6 +4,17 @@ const updateEmptyState = (element: HTMLElement, hideEmpty: boolean) => {
element.classList.toggle("protyle-db-attr--hide-empty", hideEmpty);
};
+const refreshActions = new Set<TOperation>([
+ "addAttrViewCol",
+ "removeAttrViewCol",
+ "updateAttrViewCol",
+ "sortAttrViewKey",
+ "duplicateAttrViewKey",
+ "setAttrViewColIcon",
+ "setAttrViewColDesc",
+ "setAttrViewName",
+]);
+
export class AVAttributePanel {
public element: HTMLElement;
private bodyElement: HTMLElement;
@@ -123,13 +134,18 @@ export class AVAttributePanel {
}
public refreshForOperation(operation: IOperation) {
- if (!operation.avID) {
+ const avID = operation.action === "setAttrViewName" ? operation.id : operation.avID;
+ if (!avID) {
return;
}
if (operation.action === "insertAttrViewBlock" && operation.srcs?.some(item => item.id === this.targetID)) {
this.refresh();
return;
}
+ if (refreshActions.has(operation.action) && this.hasDatabase(avID)) {
+ this.refresh();
+ return;
+ }
if (operation.action === "updateAttrViewCell" && operation.data?.type === "block" && operation.rowID &&
this.hasItem(operation.rowID)) {
this.refresh();