Improve attachment column progress meter (#5156)

* Better styling for file download progress meter #5144

* Fix download progress meters not removed on completion #5145
This commit is contained in:
Tom Najdek 2025-03-25 05:10:35 +01:00 • committed by GitHub
parent 951ed4fa4b
commit 8ec81da1d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View file

@ -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) {

View file

@ -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%);
}
}