From: Alexander Moisseev Date: Fri, 12 Dec 2025 15:29:46 +0000 (+0300) Subject: [Minor] Refactor retry loop into FooTable event X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=933e4780160c73285372e3dd5bba4ed178261870;p=thirdparty%2Frspamd.git [Minor] Refactor retry loop into FooTable event Use postinit.ft.table event instead of polling --- diff --git a/interface/js/app/libft.js b/interface/js/app/libft.js index bf4286c0ad..0d5ddb3c5c 100644 --- a/interface/js/app/libft.js +++ b/interface/js/app/libft.js @@ -7,7 +7,6 @@ define(["jquery", "app/common", "footable"], const columnsCustom = JSON.parse(localStorage.getItem("columns")) || {}; let pageSizeTimerId = null; - let pageSizeInvocationCounter = 0; function get_compare_function(table) { const compare_functions = { @@ -194,15 +193,17 @@ define(["jquery", "app/common", "footable"], if (changeTablePageSize && $("#historyTable_" + table + " tbody").is(":parent")) { // Table is not empty - clearTimeout(pageSizeTimerId); - const t = FooTable.get("#historyTable_" + table); - if (t) { - pageSizeInvocationCounter = 0; - // Wait for input finish - pageSizeTimerId = setTimeout(() => t.pageSize(n), 1000); - } else if (++pageSizeInvocationCounter < 10) { - // Wait for FooTable instance ready - pageSizeTimerId = setTimeout(() => ui.set_page_size(table, n, true), 1000); + if (common.tables[table]) { + // Table exists - debounce rapid changes (e.g., spin button clicks) + clearTimeout(pageSizeTimerId); + pageSizeTimerId = setTimeout(() => { + common.tables[table]?.pageSize(n); + }, 1000); + } else { + // Table doesn't exist - wait for initialization with event + $("#historyTable_" + table).one("postinit.ft.table", () => { + common.tables[table]?.pageSize(n); + }); } } }