From 8ec81da1d9b973a040c706bc265e0319a3152808 Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Tue, 25 Mar 2025 05:10:35 +0100 Subject: [PATCH] Improve attachment column progress meter (#5156) * Better styling for file download progress meter #5144 * Fix download progress meters not removed on completion #5145 --- chrome/content/zotero/xpcom/storage.js | 19 +++++++++++++------ scss/components/_item-tree.scss | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 1322d18feb..29deaf3cae 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -62,10 +62,11 @@ Zotero.Sync.Storage = new function () { * @param {String} libraryKey * @param {Number|NULL} */ - this.setItemDownloadPercentage = Zotero.Utilities.throttle(function (libraryKey, percentage) { + this.setItemDownloadPercentage = function (libraryKey, percentage) { Zotero.debug("Setting image download percentage to " + percentage + " for item " + libraryKey); - + + let isItemPercentageChanged = _itemDownloadPercentages[libraryKey] !== percentage; if (percentage !== false) { _itemDownloadPercentages[libraryKey] = percentage; } @@ -80,22 +81,28 @@ Zotero.Sync.Storage = new function () { if (Zotero.test && !item) { return; } - // TODO: yield or switch to queue - Zotero.Notifier.trigger('redraw', 'item', item.id, { column: "hasAttachment" }); + + if (isItemPercentageChanged) { + // TODO: yield or switch to queue + Zotero.Notifier.trigger('redraw', 'item', item.id, { column: "hasAttachment" }); + } var parent = item.parentItemKey; if (parent) { var parentItem = Zotero.Items.getByLibraryAndKey(libraryID, parent); var parentLibraryKey = libraryID + "/" + parentItem.key; + let isParentPercentageChanged = _itemDownloadPercentages[parentLibraryKey] !== percentage; if (percentage !== false) { _itemDownloadPercentages[parentLibraryKey] = percentage; } else { delete _itemDownloadPercentages[parentLibraryKey]; } - Zotero.Notifier.trigger('redraw', 'item', parentItem.id, { column: "hasAttachment" }); + if (isParentPercentageChanged) { + Zotero.Notifier.trigger('redraw', 'item', parentItem.id, { column: "hasAttachment" }); + } } - }, 25); + }; function error(e) { diff --git a/scss/components/_item-tree.scss b/scss/components/_item-tree.scss index eefc00a96f..55509438e2 100644 --- a/scss/components/_item-tree.scss +++ b/scss/components/_item-tree.scss @@ -167,7 +167,8 @@ .attachment-progress { appearance: none; background-color: transparent; - background-image: conic-gradient(var(--fill-secondary) var(--progress), transparent var(--progress)); + background-image: conic-gradient(var(--color-accent) var(--progress), var(--fill-quarternary) var(--progress), var(--fill-quarternary) 100%); + mask-image: radial-gradient(circle at center, transparent 5px, black 6px); border-radius: 8px; border: none; display: block; @@ -176,9 +177,10 @@ @include state(".row.selected") { background-image: conic-gradient(var(--color-accent-text) var(--progress), transparent var(--progress)); + background-image: conic-gradient(var(--accent-white) var(--progress), #ffffff33 var(--progress), #ffffff33 100%); @include state(".virtualized-table:not(:focus-within)") { - background-image: conic-gradient(var(--fill-secondary) var(--progress), transparent var(--progress)); + background-image: conic-gradient(var(--color-accent) var(--progress), var(--fill-quarternary) var(--progress), var(--fill-quarternary) 100%); } }