[fractal/fractal-next] sidebar: Order rooms by activity



commit 4fd6cb20adc6d5ac0f9b5715e45f7d9101d82eda
Author: Kai A. Hiller <V02460 gmail com>
Date:   Fri Aug 6 23:40:49 2021 +0200

    sidebar: Order rooms by activity

 src/session/sidebar/category.rs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/session/sidebar/category.rs b/src/session/sidebar/category.rs
index 9cb82b54..44b6dd8d 100644
--- a/src/session/sidebar/category.rs
+++ b/src/session/sidebar/category.rs
@@ -130,12 +130,19 @@ impl Category {
         });
         let filter_model = gtk::FilterListModel::new(Some(&model), Some(&filter));
 
-        filter_model.connect_items_changed(
+        let sorter = gtk::CustomSorter::new(|a, b| {
+            let a = a.downcast_ref::<Room>().unwrap();
+            let b = b.downcast_ref::<Room>().unwrap();
+            b.latest_change().cmp(&a.latest_change()).into()
+        });
+        let sort_model = gtk::SortListModel::new(Some(&filter_model), Some(&sorter));
+
+        sort_model.connect_items_changed(
             clone!(@weak self as obj => move |_, pos, added, removed| {
                 obj.items_changed(pos, added, removed);
             }),
         );
 
-        priv_.model.set(filter_model.upcast()).unwrap();
+        priv_.model.set(sort_model.upcast()).unwrap();
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]