WebUI: clear timer variable properly

In JS the timer handle pool is reused and therefore require careful handling of it.
This commit is contained in:
Chocobo1 2024-07-26 04:58:21 +08:00
parent 7131d1bd6b
commit bf7e1516d5
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
7 changed files with 18 additions and 8 deletions

View file

@ -47,7 +47,7 @@ window.qBittorrent.Search ??= (() => {
};
const searchTabIdPrefix = "Search-";
let loadSearchPluginsTimer;
let loadSearchPluginsTimer = -1;
const searchPlugins = [];
let prevSearchPluginsResponse;
let selectedCategory = "QBT_TR(All categories)QBT_TR[CONTEXT=SearchEngineWidget]";
@ -207,7 +207,7 @@ window.qBittorrent.Search ??= (() => {
rowId: 0,
selectedRowIds: [],
running: true,
loadResultsTimer: null,
loadResultsTimer: -1,
sort: { column: searchResultsTable.sortedColumn, reverse: searchResultsTable.reverseSort },
});
updateSearchResultsData(searchId);
@ -507,6 +507,7 @@ window.qBittorrent.Search ??= (() => {
},
onClose: function() {
clearTimeout(loadSearchPluginsTimer);
loadSearchPluginsTimer = -1;
}
});
}
@ -569,6 +570,7 @@ window.qBittorrent.Search ??= (() => {
if (state) {
state.running = false;
clearTimeout(state.loadResultsTimer);
state.loadResultsTimer = -1;
}
};