tehcneko 2025-04-29 20:16:00 +08:00 committed by GitHub
parent c2f2a38582
commit 0791828b84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -911,6 +911,9 @@ window.qBittorrent.DynamicTable ??= (() => {
// set the scrollable height // set the scrollable height
this.table.style.height = `${rows.length * this.rowHeight}px`; this.table.style.height = `${rows.length * this.rowHeight}px`;
if (this.dynamicTableDiv.offsetHeight === 0)
return;
this.renderedHeight = this.dynamicTableDiv.offsetHeight;
// show extra 6 rows at top/bottom to reduce flickering // show extra 6 rows at top/bottom to reduce flickering
const extraRowCount = 6; const extraRowCount = 6;
// how many rows can be shown in the visible area // how many rows can be shown in the visible area
@ -947,17 +950,22 @@ window.qBittorrent.DynamicTable ??= (() => {
this.updateRow(row, true); this.updateRow(row, true);
// refresh row height based on first row // refresh row height based on first row
setTimeout(() => { const tr = this.tableBody.firstChild;
if (this.tableBody.firstChild === null) if (tr !== null) {
return; const updateRowHeight = () => {
const tr = this.tableBody.firstChild; if (tr.offsetHeight === 0)
if (this.rowHeight !== tr.offsetHeight) { return;
this.rowHeight = tr.offsetHeight; if (this.rowHeight !== tr.offsetHeight) {
// rerender on row height change this.rowHeight = tr.offsetHeight;
this.rerender(); // rerender on row height change
} this.rerender();
}
}); };
if (tr.offsetHeight === 0)
setTimeout(updateRowHeight);
else
updateRowHeight();
}
}, },
createRowElement: function(row, top = -1) { createRowElement: function(row, top = -1) {
@ -2650,8 +2658,18 @@ window.qBittorrent.DynamicTable ??= (() => {
this._updateNodeCollapseIcon(node, shouldCollapse); this._updateNodeCollapseIcon(node, shouldCollapse);
for (const child of node.children) this._updateNodeChildVisibility(node, shouldCollapse);
this._updateNodeVisibility(child, shouldCollapse); },
_updateNodeChildVisibility: function(root, shouldHide) {
const stack = [...root.children];
while (stack.length > 0) {
const node = stack.pop();
this._updateNodeVisibility(node, (shouldHide ? shouldHide : this.isCollapsed(node.root.rowId)));
stack.push(...node.children);
}
}, },
clear: function() { clear: function() {
@ -2914,7 +2932,7 @@ window.qBittorrent.DynamicTable ??= (() => {
_filterNodes: function(node, filterTerms, filteredRows) { _filterNodes: function(node, filterTerms, filteredRows) {
if (node.isFolder && (!this.useVirtualList || !this.isCollapsed(node.rowId))) { if (node.isFolder && (!this.useVirtualList || !this.isCollapsed(node.rowId))) {
const childAdded = node.children.reduce((acc, child) => { const childAdded = node.children.toReversed().reduce((acc, child) => {
// we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match // we must execute the function before ORing w/ acc or we'll stop checking child nodes after the first successful match
return (this._filterNodes(child, filterTerms, filteredRows) || acc); return (this._filterNodes(child, filterTerms, filteredRows) || acc);
}, false); }, false);