all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 2/4] ui: dashboard: subscriptions list: update store when data changes
Date: Thu, 27 Nov 2025 15:03:46 +0100	[thread overview]
Message-ID: <20251127140451.3131469-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251127140451.3131469-1-d.csapak@proxmox.com>

by refactoring the tree creation and calling it from `changed` too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/dashboard/subscriptions_list.rs | 32 ++++++++++++++++++--------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/ui/src/dashboard/subscriptions_list.rs b/ui/src/dashboard/subscriptions_list.rs
index 77e5f876..5037a9de 100644
--- a/ui/src/dashboard/subscriptions_list.rs
+++ b/ui/src/dashboard/subscriptions_list.rs
@@ -79,17 +79,13 @@ impl ExtractPrimaryKey for SubscriptionTreeEntry {
     }
 }
 
-impl Component for PdmSubscriptionsList {
-    type Message = ();
-    type Properties = SubscriptionsList;
-
-    fn create(ctx: &yew::Context<Self>) -> Self {
-        let subscriptions = sort_subscriptions(&ctx.props().subscriptions);
-
-        let store = TreeStore::new().view_root(false);
+impl PdmSubscriptionsList {
+    fn update_store_data(&self, ctx: &yew::Context<Self>) {
+        let mut store = self.store.write();
         let mut tree = KeyedSlabTree::new();
         let mut root = tree.set_root(SubscriptionTreeEntry::Root);
         root.set_expanded(true);
+        let subscriptions = sort_subscriptions(&ctx.props().subscriptions);
 
         for remote in subscriptions {
             let mut remote_node = root.append(SubscriptionTreeEntry::Remote(RemoteEntry {
@@ -114,9 +110,25 @@ impl Component for PdmSubscriptionsList {
                 }
             }
         }
+        store.update_root_tree(tree);
+    }
+}
+
+impl Component for PdmSubscriptionsList {
+    type Message = ();
+    type Properties = SubscriptionsList;
+
+    fn create(ctx: &yew::Context<Self>) -> Self {
+        let this = Self {
+            store: TreeStore::new().view_root(false),
+        };
+        this.update_store_data(ctx);
+        this
+    }
 
-        store.write().update_root_tree(tree);
-        Self { store }
+    fn changed(&mut self, ctx: &yew::Context<Self>, _old_props: &Self::Properties) -> bool {
+        self.update_store_data(ctx);
+        true
     }
 
     fn view(&self, _ctx: &yew::Context<Self>) -> Html {
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  parent reply	other threads:[~2025-11-27 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 14:03 [pdm-devel] [PATCH datacenter-manager 0/4] improve subscription display in Dominik Csapak
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 1/4] ui: dashboard: subscriptions: refactor subscriptions show logic Dominik Csapak
2025-11-27 14:03 ` Dominik Csapak [this message]
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 3/4] ui: dashboard: subscriptions list: improve display of subscription state Dominik Csapak
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 4/4] ui: dashboard: subscriptions details: add a 'force refresh' button Dominik Csapak
2025-11-27 16:13   ` Michael Köppl
2025-11-27 21:10     ` Thomas Lamprecht
2025-11-27 16:13 ` [pdm-devel] [PATCH datacenter-manager 0/4] improve subscription display in Michael Köppl
2025-11-27 21:12 ` [pdm-devel] applied: " Thomas Lamprecht

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=20251127140451.3131469-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal