Rename _rememberOpenStates() to _saveOpenStates() in collectionTreeView
This commit is contained in:
parent
e787bb1183
commit
86b5042781
2 changed files with 13 additions and 13 deletions
|
@ -879,7 +879,7 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = Zotero.Promise.coroutine(f
|
||||||
this._rows[row].isOpen = true;
|
this._rows[row].isOpen = true;
|
||||||
this._treebox.invalidateRow(row);
|
this._treebox.invalidateRow(row);
|
||||||
this._refreshRowMap();
|
this._refreshRowMap();
|
||||||
this._startRememberOpenStatesTimer();
|
this._startSaveOpenStatesTimer();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -899,7 +899,7 @@ Zotero.CollectionTreeView.prototype._closeContainer = function (row) {
|
||||||
this._rows[row].isOpen = false;
|
this._rows[row].isOpen = false;
|
||||||
this._treebox.invalidateRow(row);
|
this._treebox.invalidateRow(row);
|
||||||
this._refreshRowMap();
|
this._refreshRowMap();
|
||||||
this._startRememberOpenStatesTimer();
|
this._startSaveOpenStatesTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -907,13 +907,13 @@ Zotero.CollectionTreeView.prototype._closeContainer = function (row) {
|
||||||
* After a short delay, persist the open states of the tree, or if already queued, cancel and requeue.
|
* After a short delay, persist the open states of the tree, or if already queued, cancel and requeue.
|
||||||
* This avoids repeated saving while opening or closing multiple rows.
|
* This avoids repeated saving while opening or closing multiple rows.
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype._startRememberOpenStatesTimer = function () {
|
Zotero.CollectionTreeView.prototype._startSaveOpenStatesTimer = function () {
|
||||||
if (this._rememberOpenStatesTimeoutID) {
|
if (this._saveOpenStatesTimeoutID) {
|
||||||
clearTimeout(this._rememberOpenStatesTimeoutID);
|
clearTimeout(this._saveOpenStatesTimeoutID);
|
||||||
}
|
}
|
||||||
this._rememberOpenStatesTimeoutID = setTimeout(() => {
|
this._saveOpenStatesTimeoutID = setTimeout(() => {
|
||||||
this._rememberOpenStates();
|
this._saveOpenStates();
|
||||||
this._rememberOpenStatesTimeoutID = null;
|
this._saveOpenStatesTimeoutID = null;
|
||||||
}, 250)
|
}, 250)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1011,10 +1011,10 @@ Zotero.CollectionTreeView.prototype.collapseLibrary = function (libraryID) {
|
||||||
this.selection.select(row);
|
this.selection.select(row);
|
||||||
|
|
||||||
// We have to manually delete closed rows from the container state object, because otherwise
|
// We have to manually delete closed rows from the container state object, because otherwise
|
||||||
// _rememberOpenStates() wouldn't see any of the rows under the library (since the library is now
|
// _saveOpenStates() wouldn't see any of the rows under the library (since the library is now
|
||||||
// collapsed) and they'd remain as open in the persisted object.
|
// collapsed) and they'd remain as open in the persisted object.
|
||||||
closed.forEach(id => { delete this._containerState[id]; });
|
closed.forEach(id => { delete this._containerState[id]; });
|
||||||
this._rememberOpenStates();
|
this._saveOpenStates();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -1385,7 +1385,7 @@ Zotero.CollectionTreeView.prototype._refreshRowMap = function() {
|
||||||
/**
|
/**
|
||||||
* Persist the current open/closed state of rows to a pref
|
* Persist the current open/closed state of rows to a pref
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype._rememberOpenStates = Zotero.Promise.coroutine(function* () {
|
Zotero.CollectionTreeView.prototype._saveOpenStates = Zotero.Promise.coroutine(function* () {
|
||||||
var state = this._containerState;
|
var state = this._containerState;
|
||||||
|
|
||||||
// Every so often, remove obsolete rows
|
// Every so often, remove obsolete rows
|
||||||
|
|
|
@ -91,7 +91,7 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
it("should open a library and respect stored container state", function* () {
|
it("should open a library and respect stored container state", function* () {
|
||||||
// Collapse B
|
// Collapse B
|
||||||
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
|
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
|
||||||
yield cv._rememberOpenStates();
|
yield cv._saveOpenStates();
|
||||||
|
|
||||||
// Close and reopen library
|
// Close and reopen library
|
||||||
yield cv.toggleOpenState(libraryRow);
|
yield cv.toggleOpenState(libraryRow);
|
||||||
|
@ -104,7 +104,7 @@ describe("Zotero.CollectionTreeView", function() {
|
||||||
|
|
||||||
it("should open a library and all subcollections in recursive mode", function* () {
|
it("should open a library and all subcollections in recursive mode", function* () {
|
||||||
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
|
yield cv.toggleOpenState(cv.getRowIndexByID(col2.treeViewID));
|
||||||
yield cv._rememberOpenStates();
|
yield cv._saveOpenStates();
|
||||||
|
|
||||||
// Close and reopen library
|
// Close and reopen library
|
||||||
yield cv.toggleOpenState(libraryRow);
|
yield cv.toggleOpenState(libraryRow);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue