]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Return promise from destroyTable
authorAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 12 Dec 2025 17:08:11 +0000 (20:08 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 12 Dec 2025 17:08:11 +0000 (20:08 +0300)
Make destroyTable return FooTable's destruction promise
and use promise chaining instead of arbitrary timeout

interface/js/app/history.js
interface/js/app/libft.js

index 966d6f3e46d21e7eb14171b39f6635424cdb3a33..579bab9dbab3c16047a45bbd84b604bcd0330cfc 100644 (file)
@@ -195,15 +195,13 @@ define(["jquery", "app/common", "app/libft", "footable"],
                             version === prevVersion) {
                             common.tables.history.rows.load(items);
                         } else {
-                            libft.destroyTable("history");
-                            // Is there a way to get an event when the table is destroyed?
-                            setTimeout(() => {
+                            libft.destroyTable("history").then(() => {
                                 libft.initHistoryTable(data, items, "history", get_history_columns(data), false,
                                     () => {
                                         $("#history .ft-columns-dropdown .btn-dropdown-apply").removeAttr("disabled");
                                         ui.updateHistoryControlsState();
                                     });
-                            }, 200);
+                            });
                         }
                         prevVersion = version;
                     } else {
index 0d5ddb3c5c4f7f7c27f6e71ebeda4660b9b467f2..0d2024b42283e86ee54eb46f7972ba323f5d1aa3 100644 (file)
@@ -235,9 +235,11 @@ define(["jquery", "app/common", "footable"],
             $("#" + table + " .ft-columns-btn.show").trigger("click.bs.dropdown"); // Hide dropdown
             $("#" + table + " .ft-columns-btn").attr("disabled", true);
             if (common.tables[table]) {
-                common.tables[table].destroy();
+                const promise = common.tables[table].destroy();
                 delete common.tables[table];
+                return promise;
             }
+            return new $.Deferred().resolve().promise();
         };
 
         ui.initHistoryTable = function (data, items, table, columnsDefault, expandFirst, postdrawCallback) {