Skip to content

Commit

Permalink
fix: note link section count exclude invalid items
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Dec 13, 2024
1 parent a667f8a commit c6d4d93
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/modules/workspace/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async function renderSection(
outbound: addon.api.relation.getNoteLinkOutboundRelation,
};
const inLinks = await api[type](item.id);
let count = 0;
for (const linkData of inLinks) {
const targetItem = (await Zotero.Items.getByLibraryAndKeyAsync(
linkData[
Expand All @@ -108,7 +109,12 @@ async function renderSection(
linkData[
{ inbound: "fromKey", outbound: "toKey" }[type] as "fromKey" | "toKey"
],
)) as Zotero.Item;
)) as Zotero.Item | false;

if (!targetItem) {
continue;
}
count ++;

const linkParams = {
workspaceUID: (body.closest("bn-workspace") as Workspace)?.dataset.uid,
Expand Down Expand Up @@ -160,7 +166,6 @@ async function renderSection(
body.append(row);
}

const count = inLinks.length;
setCount(count);
}

Expand Down

0 comments on commit c6d4d93

Please sign in to comment.