[fractal/fractal-next] session: Load rooms from state store



commit 69fe574e2c5ef7a0920a9c15478c4b26f86a3587
Author: Julian Sparber <julian sparber net>
Date:   Tue May 11 16:21:14 2021 +0200

    session: Load rooms from state store

 src/session/mod.rs | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/session/mod.rs b/src/session/mod.rs
index 5981a315..d150dfd4 100644
--- a/src/session/mod.rs
+++ b/src/session/mod.rs
@@ -354,7 +354,20 @@ impl Session {
     /// Note that the `Store` currently doesn't store all events, therefore, we arn't really
     /// loading much via this function.
     pub fn load(&self) {
-        // TODO: load rooms from the store before the sync completes
+        let priv_ = imp::Session::from_instance(self);
+        let rooms = priv_.client.get().unwrap().rooms();
+
+        let mut new_rooms = Vec::with_capacity(rooms.len());
+        let mut rooms_map = priv_.rooms.borrow_mut();
+
+        for matrix_room in rooms {
+            let room_id = matrix_room.room_id().clone();
+            let room = Room::new(matrix_room, self.user());
+            rooms_map.insert(room_id, room.clone());
+            new_rooms.push(room.clone());
+        }
+
+        priv_.categories.append(new_rooms);
     }
 
     /// Returns and consumes the `error` that was generated when the session failed to login,


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