Skip to content

Commit

Permalink
Merge pull request #125 from ChenglongMa/dev-3.0.4+
Browse files Browse the repository at this point in the history
Release 3.0.5
  • Loading branch information
ChenglongMa authored Dec 12, 2024
2 parents a1989ef + ce45113 commit a5b3fbc
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 12 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ A plugin that does one thing only: **Detect** and **Manage** duplicate items in
# Changelog

## v3.0.5

<details markdown="1" open>
<summary><i>Click here to show more.</i></summary>

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).

</details>

## v3.0.4

<details markdown="1" open>
Expand Down
5 changes: 2 additions & 3 deletions addon/chrome/content/zoplicate.css
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions src/modules/bulkDuplicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/duplicateItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/modules/duplicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/modules/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/modules/patcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion update-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]": {
"updates": [
{
"version": "3.0.4",
"version": "3.0.5",
"update_link": "https://github.com/ChenglongMa/zoplicate/releases/latest/download/zoplicate.xpi",
"applications": {
"zotero": {
Expand Down
2 changes: 1 addition & 1 deletion update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"[email protected]": {
"updates": [
{
"version": "3.0.4",
"version": "3.0.5",
"update_link": "https://github.com/ChenglongMa/zoplicate/releases/latest/download/zoplicate.xpi",
"applications": {
"zotero": {
Expand Down

0 comments on commit a5b3fbc

Please sign in to comment.