From bf5280656f62921b5248463e96963bd5f220d850 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:47:57 +0800 Subject: [PATCH] refactor: api.related -> api.relation --- src/api.ts | 4 ++-- src/elements/outlinePane.ts | 2 +- src/elements/workspace.ts | 2 +- src/modules/editor/toolbar.ts | 2 +- src/modules/relatedNotes.ts | 2 +- src/modules/sync/infoWindow.ts | 2 +- src/modules/workspace/relation.ts | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/api.ts b/src/api.ts index 1670042..a26dc52 100644 --- a/src/api.ts +++ b/src/api.ts @@ -148,7 +148,7 @@ const note = { getNoteTreeFlattened, }; -const related = { +const relation = { getNoteLinkInboundRelation, getNoteLinkOutboundRelation, updateNoteLinkRelation, @@ -163,5 +163,5 @@ export default { $import, editor, note, - related, + relation, }; diff --git a/src/elements/outlinePane.ts b/src/elements/outlinePane.ts index 8879abb..ab649ab 100644 --- a/src/elements/outlinePane.ts +++ b/src/elements/outlinePane.ts @@ -169,7 +169,7 @@ export class OutlinePane extends PluginCEBase { if (event === "modify" && type === "item") { if ((ids as number[]).includes(this.item.id)) { this.updateOutline(); - this._addon.api.related.updateNoteLinkRelation(this.item.id); + this._addon.api.relation.updateNoteLinkRelation(this.item.id); } } } diff --git a/src/elements/workspace.ts b/src/elements/workspace.ts index 9126e17..c57ce28 100644 --- a/src/elements/workspace.ts +++ b/src/elements/workspace.ts @@ -59,7 +59,7 @@ export class Workspace extends PluginCEBase { set item(val) { if (!val) return; - this._addon.api.related.updateNoteLinkRelation(val.id); + this._addon.api.relation.updateNoteLinkRelation(val.id); this._item = val; this._outline.item = val; this._context.item = val; diff --git a/src/modules/editor/toolbar.ts b/src/modules/editor/toolbar.ts index db42abc..3c1f4df 100644 --- a/src/modules/editor/toolbar.ts +++ b/src/modules/editor/toolbar.ts @@ -174,7 +174,7 @@ async function getMenuData(editor: Zotero.EditorInstance) { id: makeId("settings-updateRelatedNotes"), text: getString("editor-toolbar-settings-updateRelatedNotes"), callback: (e) => { - addon.api.related.updateNoteLinkRelation(e.editor._item.id); + addon.api.relation.updateNoteLinkRelation(e.editor._item.id); }, }, ]), diff --git a/src/modules/relatedNotes.ts b/src/modules/relatedNotes.ts index f1b18fc..836d53f 100644 --- a/src/modules/relatedNotes.ts +++ b/src/modules/relatedNotes.ts @@ -2,6 +2,6 @@ export { onUpdateRelated }; function onUpdateRelated(items: Zotero.Item[] = []) { for (const item of items) { - addon.api.related.updateNoteLinkRelation(item.id); + addon.api.relation.updateNoteLinkRelation(item.id); } } diff --git a/src/modules/sync/infoWindow.ts b/src/modules/sync/infoWindow.ts index 9d3d656..b3b7910 100644 --- a/src/modules/sync/infoWindow.ts +++ b/src/modules/sync/infoWindow.ts @@ -45,7 +45,7 @@ export async function showSyncInfo(noteId: number) { .addButton(getString("syncInfo.unSync"), "unSync", { callback: async (ev) => { const outLink = - await addon.api.related.getNoteLinkOutboundRelation(noteId); + await addon.api.relation.getNoteLinkOutboundRelation(noteId); for (const linkData of outLink) { const noteItem = await Zotero.Items.getByLibraryAndKeyAsync( linkData.toLibID, diff --git a/src/modules/workspace/relation.ts b/src/modules/workspace/relation.ts index 3e3244e..9667f2c 100644 --- a/src/modules/workspace/relation.ts +++ b/src/modules/workspace/relation.ts @@ -78,8 +78,8 @@ async function refresh(body: HTMLElement, item: Zotero.Item) { async function getRelationData(note: Zotero.Item) { if (!note) return; - const inLink = await addon.api.related.getNoteLinkInboundRelation(note.id); - const outLink = await addon.api.related.getNoteLinkOutboundRelation(note.id); + const inLink = await addon.api.relation.getNoteLinkInboundRelation(note.id); + const outLink = await addon.api.relation.getNoteLinkOutboundRelation(note.id); const links = []; const noteSet: Set = new Set();