public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] applied: [PATCH] ui: dc/Guests: make update lazy
@ 2021-07-05 10:27 Thomas Lamprecht
  0 siblings, 0 replies; only message in thread
From: Thomas Lamprecht @ 2021-07-05 10:27 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 www/manager6/dc/Guests.js | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/www/manager6/dc/Guests.js b/www/manager6/dc/Guests.js
index 0707dd9f..df233b6d 100644
--- a/www/manager6/dc/Guests.js
+++ b/www/manager6/dc/Guests.js
@@ -118,8 +118,21 @@ Ext.define('PVE.dc.Guests', {
 
     updateValues: function(qemu, lxc, error) {
 	let me = this;
-	me.getComponent('qemu').update(qemu);
-	me.getComponent('lxc').update(lxc);
-	me.getComponent('error').update({ num: error });
+
+	let lazyUpdate = (query, newData) => {
+	    let el = me.getComponent(query);
+            let currentData = el.data;
+
+	    let keys = Object.keys(newData);
+	    if (keys.length === Object.keys(currentData).length) {
+		if (keys.every(k => newData[k] === currentData[k])) {
+		    return; // all stayed the same here, return early to avoid bogus regeneration
+		}
+	    }
+	    el.update(newData);
+	};
+	lazyUpdate('qemu', qemu);
+	lazyUpdate('lxc', lxc);
+	lazyUpdate('error', { num: error });
     },
 });
-- 
2.30.2





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-05 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 10:27 [pve-devel] applied: [PATCH] ui: dc/Guests: make update lazy Thomas Lamprecht

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