mirror of
https://github.com/zotero/zotero.git
synced 2026-09-27 01:21:27 +00:00
Fx140: do not use bluebird methods in citation dialog (#5416)
Instead, decide if the search should be skipped after the delay based on the timestamps. Fixes: #5414
This commit is contained in:
parent
0a33eeb0c0
commit
2e135d035f
1 changed files with 10 additions and 8 deletions
|
|
@ -197,7 +197,7 @@ function _id(id) {
|
|||
class Layout {
|
||||
constructor(type) {
|
||||
this.type = type;
|
||||
this._searchDebouncePromise = null;
|
||||
this._lastSearchTime = null;
|
||||
}
|
||||
|
||||
// Re-render the items based on search results
|
||||
|
|
@ -319,15 +319,17 @@ class Layout {
|
|||
await this.refreshItemsList({ skipWindowResize: true });
|
||||
|
||||
// debounce to not rerun sql search until typing is probably done
|
||||
if (this._searchDebouncePromise && this._searchDebouncePromise.isPending()) {
|
||||
this._searchDebouncePromise.cancel();
|
||||
}
|
||||
if (!skipDebounce) {
|
||||
this._searchDebouncePromise = Zotero.Promise.delay(SEARCH_TIMEOUT);
|
||||
await this._searchDebouncePromise;
|
||||
// record when the search started
|
||||
let searchStartTime = Date.now();
|
||||
this._lastSearchTime = searchStartTime;
|
||||
|
||||
// wait a moment
|
||||
await Zotero.Promise.delay(SEARCH_TIMEOUT);
|
||||
|
||||
// stop if another search started during the delay
|
||||
if (this._lastSearchTime !== searchStartTime) return;
|
||||
}
|
||||
this._searchDebouncePromise = null;
|
||||
|
||||
// in list mode, search for matches across libraries
|
||||
// in library mode, set filter on itemTree
|
||||
if (this.type == "list") {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue