mirror of
https://github.com/zotero/zotero.git
synced 2026-08-28 05:25:31 +00:00
Fix lost item tree column choices after item tree refactor
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run
Before the refactor, main library column prefs were keyed under "<id>-default", because the visibilityGroup getter returns 'default' (truthy) for the main library. The refactor changed the suffix logic to only append non-default groups, leaving existing prefs orphaned at "<id>-default" while the new code reads/writes "<id>". Fall back to the legacy key on load when the new key is missing or an empty object (which can be written out by an unmodified post-refactor build that flushed prefs on a visibility-group switch, like switching to feeds), and drop the legacy key on the next write. https://forums.zotero.org/discussion/131202/lost-columns-displayed-choice-in-the-items-tree-after-update-to-10-beta-4
This commit is contained in:
parent
178f162449
commit
ef7896ab5f
1 changed files with 10 additions and 1 deletions
|
|
@ -2395,7 +2395,15 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
try {
|
||||
let columnPrefs = await Zotero.File.getContentsAsync(COLUMN_PREFS_FILEPATH);
|
||||
let persistSettings = JSON.parse(columnPrefs);
|
||||
this._columnPrefs = persistSettings[this.id] || {};
|
||||
// Fall back to the pre-item-tree-refactor "<id>-default" key,
|
||||
// including when "<id>" is an empty object written out by an
|
||||
// earlier post-refactor beta before this fallback was added.
|
||||
// _writeColumnPrefsToFile() removes it on the next write.
|
||||
let prefs = persistSettings[this.id];
|
||||
if (!prefs || !Object.keys(prefs).length) {
|
||||
prefs = persistSettings[this.id + '-default'];
|
||||
}
|
||||
this._columnPrefs = prefs || {};
|
||||
}
|
||||
catch (e) {
|
||||
this._columnPrefs = {};
|
||||
|
|
@ -2419,6 +2427,7 @@ var ItemTree = class ItemTree extends LibraryTree {
|
|||
persistSettings = {};
|
||||
}
|
||||
persistSettings[this.id] = this._columnPrefs;
|
||||
delete persistSettings[this.id + '-default'];
|
||||
|
||||
let prefString = JSON.stringify(persistSettings);
|
||||
Zotero.debug(`Writing column prefs of length ${prefString.length} to file ${COLUMN_PREFS_FILEPATH}`);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue