Skip to content

Commit 7297225

Browse files
authored
Revert "WebUI: Improve table performance" partially
This change is incomplete and causes RSS to spam errors in browser console. Fix up: #23752. PR #23820.
1 parent 4425aea commit 7297225

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/webui/www/private/scripts/dynamicTable.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ window.qBittorrent.DynamicTable ??= (() => {
8383
this.rowHeight = (clientData.get("display_density") === "compact") ? 22 : 26;
8484
this.rows = new Map();
8585
this.cachedElements = [];
86-
this.selectedRows = new Set();
86+
this.selectedRows = [];
8787
this.columns = [];
8888
this.contextMenu = contextMenu;
8989
this.sortedColumn = localPreferences.get(`sorted_column_${this.dynamicTableDivId}`, 0);
@@ -144,7 +144,7 @@ window.qBittorrent.DynamicTable ??= (() => {
144144
else
145145
this.selectRow(tr.rowId);
146146
}
147-
else if (e.shiftKey && (this.selectedRows.size === 1)) {
147+
else if (e.shiftKey && (this.selectedRows.length === 1)) {
148148
// Shift key was pressed
149149
this.selectRows(this.getSelectedRowId(), tr.rowId);
150150
}
@@ -719,13 +719,13 @@ window.qBittorrent.DynamicTable ??= (() => {
719719
}
720720

721721
getSelectedRowId() {
722-
if (this.selectedRows.size > 0)
723-
return this.selectedRows.values().next().value;
722+
if (this.selectedRows.length > 0)
723+
return this.selectedRows[0];
724724
return "";
725725
}
726726

727727
isRowSelected(rowId) {
728-
return this.selectedRows.has(rowId);
728+
return this.selectedRows.contains(rowId);
729729
}
730730

731731
setupAltRow() {
@@ -737,22 +737,22 @@ window.qBittorrent.DynamicTable ??= (() => {
737737
selectAll() {
738738
this.deselectAll();
739739
for (const row of this.getFilteredAndSortedRows())
740-
this.selectedRows.add(row.rowId);
740+
this.selectedRows.push(row.rowId);
741741
this.setRowClass();
742742
}
743743

744744
deselectAll() {
745-
this.selectedRows.clear();
745+
this.selectedRows.empty();
746746
}
747747

748748
selectRow(rowId) {
749-
this.selectedRows.add(rowId);
749+
this.selectedRows.push(rowId);
750750
this.setRowClass();
751751
this.onSelectedRowChanged();
752752
}
753753

754754
deselectRow(rowId) {
755-
this.selectedRows.delete(rowId);
755+
this.selectedRows.erase(rowId);
756756
this.setRowClass();
757757
this.onSelectedRowChanged();
758758
}
@@ -768,10 +768,10 @@ window.qBittorrent.DynamicTable ??= (() => {
768768
for (const row of this.getFilteredAndSortedRows()) {
769769
if ((row.rowId === rowId1) || (row.rowId === rowId2)) {
770770
select = !select;
771-
this.selectedRows.add(row.rowId);
771+
this.selectedRows.push(row.rowId);
772772
}
773773
else if (select) {
774-
this.selectedRows.add(row.rowId);
774+
this.selectedRows.push(row.rowId);
775775
}
776776
}
777777
this.setRowClass();
@@ -780,7 +780,7 @@ window.qBittorrent.DynamicTable ??= (() => {
780780

781781
reselectRows(rowIds) {
782782
this.deselectAll();
783-
this.selectedRows = new Set(rowIds);
783+
this.selectedRows = rowIds.slice();
784784
this.setRowClass();
785785
}
786786

@@ -872,9 +872,11 @@ window.qBittorrent.DynamicTable ??= (() => {
872872
updateTable(fullUpdate = false) {
873873
const rows = this.getFilteredAndSortedRows();
874874

875-
for (const rowId of this.selectedRows) {
876-
if (!(rowId in rows))
877-
this.selectedRows.delete(rowId);
875+
for (let i = 0; i < this.selectedRows.length; ++i) {
876+
if (!(this.selectedRows[i] in rows)) {
877+
this.selectedRows.splice(i, 1);
878+
--i;
879+
}
878880
}
879881

880882
if (this.useVirtualList) {
@@ -1032,7 +1034,7 @@ window.qBittorrent.DynamicTable ??= (() => {
10321034
}
10331035

10341036
removeRow(rowId) {
1035-
this.selectedRows.delete(rowId);
1037+
this.selectedRows.erase(rowId);
10361038
this.rows.delete(rowId);
10371039
if (this.useVirtualList) {
10381040
this.rerender();
@@ -1056,7 +1058,7 @@ window.qBittorrent.DynamicTable ??= (() => {
10561058
}
10571059

10581060
selectedRowsIds() {
1059-
return [...this.selectedRows];
1061+
return this.selectedRows.slice();
10601062
}
10611063

10621064
getRowIds() {

0 commit comments

Comments
 (0)