From c4e7bf3aee134a9cdea73ba01f7d0ff707fa841d Mon Sep 17 00:00:00 2001 From: ChenglongMa Date: Sat, 7 Dec 2024 20:47:59 +1100 Subject: [PATCH 1/4] Fix menu flashing issue --- src/modules/menus.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/menus.ts b/src/modules/menus.ts index 308becb..a05de51 100644 --- a/src/modules/menus.ts +++ b/src/modules/menus.ts @@ -64,12 +64,11 @@ function registerItemsViewMenu(menuManager: MenuManager, win: Window) { } const selectedItems = Zotero.getActiveZoteroPane().getSelectedItems(); const mainMenu = win.document.getElementById(`${config.addonRef}-itemsview-menu`) as HTMLElement; + mainMenu.setAttribute("hidden", "true"); const showing = selectedItems.length > 1; if (!showing) { - mainMenu.setAttribute("hidden", "true"); return; } - mainMenu.removeAttribute("hidden"); const isDuplicateMenuItem = win.document.getElementById( `${config.addonRef}-menuitem-is-duplicate`, ) as HTMLElement; @@ -81,6 +80,7 @@ function registerItemsViewMenu(menuManager: MenuManager, win: Window) { setTimeout(async () => { showingIsDuplicate = await NonDuplicatesDB.instance.existsNonDuplicates(itemIDs); if (showingIsDuplicate) { + mainMenu.removeAttribute("hidden"); isDuplicateMenuItem.removeAttribute("hidden"); notDuplicateMenuItem.setAttribute("hidden", "true"); } else { @@ -91,6 +91,7 @@ function registerItemsViewMenu(menuManager: MenuManager, win: Window) { showingNotDuplicate = itemIDs.every((itemID) => duplicateItems.has(itemID)); if (showingNotDuplicate) { + mainMenu.removeAttribute("hidden"); notDuplicateMenuItem.removeAttribute("hidden"); } else { notDuplicateMenuItem.setAttribute("hidden", "true"); From 5a7e3e680c44a45682d05e56b0625c25ddd8c9ef Mon Sep 17 00:00:00 2001 From: ChenglongMa Date: Sun, 8 Dec 2024 01:39:08 +1100 Subject: [PATCH 2/4] Fix button style, #120 --- addon/chrome/content/zoplicate.css | 5 ++--- src/modules/duplicates.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addon/chrome/content/zoplicate.css b/addon/chrome/content/zoplicate.css index 3b4bdc8..be53e01 100644 --- a/addon/chrome/content/zoplicate.css +++ b/addon/chrome/content/zoplicate.css @@ -1,16 +1,15 @@ .duplicate-custom-head { display: flex; - flex-direction: row; + flex-direction: column; align-self: stretch; gap: 6px; padding: 6px 8px; background: var(--material-toolbar); border-bottom: var(--material-panedivider); - height: 28px; } .duplicate-custom-head button { - height: 26px; + height: 28px; margin: 0; flex-grow: 1; cursor: pointer; diff --git a/src/modules/duplicates.ts b/src/modules/duplicates.ts index f109ae5..c789e09 100644 --- a/src/modules/duplicates.ts +++ b/src/modules/duplicates.ts @@ -21,7 +21,7 @@ function addButtonsInDuplicatePanes(innerButton: boolean, siblingElement: Elemen { tag: "div", namespace: "html", - classList: ["duplicate-custom-head", "empty"], + classList: ["duplicate-custom-head"], children: [ BulkDuplicates.instance.createBulkMergeButton(siblingElement.ownerDocument.defaultView!, mergeButtonID), createNonDuplicateButton(nonDuplicateButtonID), From ac9f7c048b0e993ad59b7fdbeb891ea8569cf7b1 Mon Sep 17 00:00:00 2001 From: ChenglongMa Date: Fri, 13 Dec 2024 00:07:27 +1100 Subject: [PATCH 3/4] Fix sync error, #124 --- src/modules/bulkDuplicates.ts | 4 ++++ src/modules/duplicateItems.ts | 2 +- src/modules/duplicates.ts | 3 +++ src/modules/patcher.ts | 4 ++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/bulkDuplicates.ts b/src/modules/bulkDuplicates.ts index 165d487..7867346 100644 --- a/src/modules/bulkDuplicates.ts +++ b/src/modules/bulkDuplicates.ts @@ -141,6 +141,10 @@ export class BulkDuplicates { if (processedItems.has(duplicateItem)) continue; const items: number[] = duplicatesObj.getSetItemsByItemID(duplicateItem); + if (items.length < 2) { + processedItems.add(duplicateItem); + continue; + } const duItems = new DuplicateItems(items, masterItemPref); popWin.changeLine({ text: getString("bulk-merge-popup-process", { diff --git a/src/modules/duplicateItems.ts b/src/modules/duplicateItems.ts index d3a25f7..22d30de 100644 --- a/src/modules/duplicateItems.ts +++ b/src/modules/duplicateItems.ts @@ -13,7 +13,7 @@ export class DuplicateItems { constructor(items: Zotero.Item[] | number[], masterItemPref: MasterItem) { if (items.length < 1) { - throw new Error("DuplicateItems must have at least one item"); + ztoolkit.log("DuplicateItems must have at least one item"); } this._masterItemPref = masterItemPref; diff --git a/src/modules/duplicates.ts b/src/modules/duplicates.ts index c789e09..00d544e 100644 --- a/src/modules/duplicates.ts +++ b/src/modules/duplicates.ts @@ -183,6 +183,9 @@ export class Duplicates { otherItems: existingItemIDs.map((id) => Zotero.Items.get(id)), }); } else if (action === Action.DISCARD) { + if (existingItemIDs.length < 1) { + continue; + } const duplicateItems = new DuplicateItems(existingItemIDs, masterItemPref); const masterItem = duplicateItems.masterItem; const otherItems = duplicateItems.otherItems; diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 19b34a4..fd39a7c 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -81,10 +81,10 @@ export function patchItemSaveData() { ztoolkit.log("Parent item", parentID, "deleted?", parentItem?.deleted); if (parentItem && parentItem.deleted) { const newParents = await new DuplicateFinder(parentItem).find(); - const masterItemPref = getPref("bulk.master.item") as MasterItem; - const duItems = new DuplicateItems(newParents, masterItemPref); if (newParents.length > 0) { + const masterItemPref = getPref("bulk.master.item") as MasterItem; + const duItems = new DuplicateItems(newParents, masterItemPref); // TODO: check if this is correct, should use official API // Such as Zotero.Items.moveChildItems, etc. this.parentID = duItems.masterItem.id; From ce451130d4ab936108cf5f9dc9992aa904724dfe Mon Sep 17 00:00:00 2001 From: ChenglongMa Date: Fri, 13 Dec 2024 00:11:43 +1100 Subject: [PATCH 4/4] Release 3.0.5 --- README.md | 14 ++++++++++++++ package.json | 2 +- update-beta.json | 2 +- update.json | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dcdf610..30bc109 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,20 @@ A plugin that does one thing only: **Detect** and **Manage** duplicate items in # Changelog +## v3.0.5 + +
+ Click here to show more. + +In this version, we have made the following changes: + +1. 🐛 **FIX!**: We have fixed the bug that caused the sync error. + * Thanks to [dstillman](https://github.com/dstillman) for reporting this issue in [issue #124](https://github.com/ChenglongMa/zoplicate/issues/124). +2. 🐛 **FIX!**: We have optimized the UI of context menu. + * Thanks to [dschaehi](https://github.com/dschaehi) for reporting this issue in [issue #119](https://github.com/ChenglongMa/zoplicate/issues/119). + +
+ ## v3.0.4
diff --git a/package.json b/package.json index eaeb071..d12d442 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zoplicate", - "version": "3.0.4", + "version": "3.0.5", "description": "Detect and manage duplicate items in Zotero.", "config": { "addonName": "Zoplicate", diff --git a/update-beta.json b/update-beta.json index ba79e7e..af4ae03 100644 --- a/update-beta.json +++ b/update-beta.json @@ -3,7 +3,7 @@ "zoplicate@chenglongma.com": { "updates": [ { - "version": "3.0.4", + "version": "3.0.5", "update_link": "https://github.com/ChenglongMa/zoplicate/releases/latest/download/zoplicate.xpi", "applications": { "zotero": { diff --git a/update.json b/update.json index ba79e7e..af4ae03 100644 --- a/update.json +++ b/update.json @@ -3,7 +3,7 @@ "zoplicate@chenglongma.com": { "updates": [ { - "version": "3.0.4", + "version": "3.0.5", "update_link": "https://github.com/ChenglongMa/zoplicate/releases/latest/download/zoplicate.xpi", "applications": { "zotero": {