From 815ace22d0d23f25efea324f01e0329e42a88160 Mon Sep 17 00:00:00 2001 From: Simon Cordt Date: Sat, 27 Sep 2025 10:14:10 +0200 Subject: [PATCH] Refactor: Update summary on state updates --- web/js/pqueue.events.js | 8 ++++++++ web/js/pqueue.runtime.js | 1 + web/js/pqueue.ui.render.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/web/js/pqueue.events.js b/web/js/pqueue.events.js index d926cf3..fba086a 100644 --- a/web/js/pqueue.events.js +++ b/web/js/pqueue.events.js @@ -97,6 +97,7 @@ console.error("pqueue: toggle pause failed", err); state.error = err?.message || "Failed to toggle queue"; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -116,6 +117,7 @@ console.error("pqueue: clear failed", err); state.error = err?.message || "Failed to clear queue"; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -242,6 +244,7 @@ console.error("pqueue: reorder failed", err); state.error = err?.message || "Failed to reorder queue"; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -269,6 +272,7 @@ console.error("pqueue: delete failed", err); state.error = err?.message || "Failed to delete prompt"; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -297,6 +301,7 @@ console.error('pqueue: move failed', err); state.error = err?.message || 'Failed to move prompt'; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -367,6 +372,7 @@ /* ignore load errors to avoid UI jank */ } finally { if (state.historyPaging) state.historyPaging.isLoading = false; + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -638,6 +644,7 @@ console.error("pqueue: bulk delete failed", err); state.error = err?.message || "Failed to delete prompts"; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, @@ -683,6 +690,7 @@ console.error(`pqueue: ${action} selected jobs failed`, err); state.error = err?.message || `Failed to ${action} selected jobs`; UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (e) { /* noop */ } } }, diff --git a/web/js/pqueue.runtime.js b/web/js/pqueue.runtime.js index 07c6d89..f2a2289 100644 --- a/web/js/pqueue.runtime.js +++ b/web/js/pqueue.runtime.js @@ -81,6 +81,7 @@ state.isRefreshing = false; if (!state.dom || !state.dom.root) UI.render(); UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (err) { /* noop */ } } }; diff --git a/web/js/pqueue.ui.render.js b/web/js/pqueue.ui.render.js index a351d94..5fc065f 100644 --- a/web/js/pqueue.ui.render.js +++ b/web/js/pqueue.ui.render.js @@ -83,12 +83,13 @@ UI.refreshFilter(); UI.updateSelectionUI(); UI.updateToolbarStatus(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (err) { /* noop */ } }; UI.updateAfterRefresh = function updateAfterRefresh(paged) { try { UI.updateToolbarControls(); - UI.updateMetrics(); + try { if (typeof UI.updateToolbarSummary === 'function') UI.updateToolbarSummary(); } catch (err) { /* noop */ } UI.updateRunningSection(); UI.updatePendingSection(); UI.reconcileHistoryFromState();