WebUI: Delete correct rows after re-sort

The previous logic assumed that trs was properly sorted, which is no longer the case.
Follow up to #22827.

PR #22884.
This commit is contained in:
Thomas Piccirello 2025-06-22 03:35:07 -04:00 committed by GitHub
parent 254f39f89d
commit 67ef356064
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -886,6 +886,7 @@ window.qBittorrent.DynamicTable ??= (() => {
for (let rowPos = 0; rowPos < rows.length; ++rowPos) { for (let rowPos = 0; rowPos < rows.length; ++rowPos) {
const { rowId } = rows[rowPos]; const { rowId } = rows[rowPos];
const tr = trMap.get(rowId); const tr = trMap.get(rowId);
trMap.delete(rowId);
const isInCorrectLocation = rowId === trs[rowPos]?.rowId; const isInCorrectLocation = rowId === trs[rowPos]?.rowId;
if (!isInCorrectLocation) { if (!isInCorrectLocation) {
@ -904,10 +905,8 @@ window.qBittorrent.DynamicTable ??= (() => {
prevTr = tr; prevTr = tr;
} }
const rowPos = rows.length; for (const tr of trMap.values())
tr.remove();
while ((rowPos < trs.length) && (trs.length > 0))
trs.pop().remove();
} }
} }