[pdm-devel] [PATCH datacenter-manager 2/4] ui: dashboard: subscriptions list: update store when data changes

Dominik Csapak d.csapak at proxmox.com
Thu Nov 27 15:03:46 CET 2025


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

Signed-off-by: Dominik Csapak <d.csapak at 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





More information about the pdm-devel mailing list