Remove elements from pane.persist that no longer persist anything

This commit is contained in:
Dan Stillman 2024-04-18 08:23:59 -04:00 committed by Dan Stillman
parent 9d49d4623d
commit ff3c249b6d

View file

@ -6074,7 +6074,7 @@ var ZoteroPane = new function()
};
/**
* Serializes zotero-persist elements to preferences
* Serializes zotero-persist attributes to preferences
*/
this.serializePersist = function() {
if (!_unserialized) return;
@ -6084,6 +6084,7 @@ var ZoteroPane = new function()
catch (e) {
serializedValues = {};
}
var persistedElements = new Set();
for (let el of document.querySelectorAll("[zotero-persist]")) {
if (!el.getAttribute) continue;
var id = el.getAttribute("id");
@ -6092,10 +6093,17 @@ var ZoteroPane = new function()
for (let attr of el.getAttribute("zotero-persist").split(/[\s,]+/)) {
if (el.hasAttribute(attr)) {
elValues[attr] = el.getAttribute(attr);
persistedElements.add(id);
}
}
serializedValues[id] = elValues;
}
// Remove elements that no longer persist anything
for (let i in serializedValues) {
if (!persistedElements.has(i)) {
delete serializedValues[i];
}
}
Zotero.Prefs.set("pane.persist", JSON.stringify(serializedValues));
}