public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] applied: [PATCH] ui: fire config change: always pass required parameters
Date: Fri, 10 Mar 2023 15:41:31 +0100	[thread overview]
Message-ID: <20230310144131.402390-1-t.lamprecht@proxmox.com> (raw)

As otherwise the listeners might choke on the missing records.

For our usage it was only a problem when one changed the tree UI
options while having the Datacenter -> Summary panel open, as that
listens to the UI changes to adapt the shown gauges for e.g., memory,
storage, or CPUs, and thus actually uses the current result (unlike
we do in the store load listener).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/UIOptions.js          | 4 +---
 www/manager6/data/ResourceStore.js | 9 +++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/www/manager6/UIOptions.js b/www/manager6/UIOptions.js
index cb5a1755..057c8f03 100644
--- a/www/manager6/UIOptions.js
+++ b/www/manager6/UIOptions.js
@@ -99,9 +99,7 @@ Ext.define('PVE.UIOptions', {
     },
 
     fireUIConfigChanged: function() {
-	if (!PVE.data.ResourceStore.isLoading() && PVE.data.ResourceStore.isLoaded()) {
-	    PVE.data.ResourceStore.fireEvent('load');
-	}
+	PVE.data.ResourceStore.refresh();
 	Ext.GlobalEvents.fireEvent('loadedUiOptions');
     },
 });
diff --git a/www/manager6/data/ResourceStore.js b/www/manager6/data/ResourceStore.js
index f3a5c4d8..76da3f08 100644
--- a/www/manager6/data/ResourceStore.js
+++ b/www/manager6/data/ResourceStore.js
@@ -53,6 +53,15 @@ Ext.define('PVE.data.ResourceStore', {
 	return '';
     },
 
+    refresh: function() {
+	let me = this;
+	// can only refresh if we're loaded at least once and are not currently loading
+	if (!me.isLoading() && me.isLoaded()) {
+	    let records = (me.getData().getSource() || me.getData()).getRange()
+	    me.fireEvent('load', me, records);
+	}
+    },
+
     constructor: function(config) {
 	let me = this;
 
-- 
2.39.2





                 reply	other threads:[~2023-03-10 14:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230310144131.402390-1-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal