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: dc/Guests: make update lazy
Date: Mon,  5 Jul 2021 12:27:15 +0200	[thread overview]
Message-ID: <20210705102715.2509372-1-t.lamprecht@proxmox.com> (raw)

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





                 reply	other threads:[~2021-07-05 10:27 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=20210705102715.2509372-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