[fractal] refactor: pass rooms to set_rooms by value



commit f32f9cee64c4cc22d159aaebde53fbb4e89aadd7
Author: Julian Sparber <julian sparber net>
Date:   Sat Dec 22 16:43:55 2018 +0100

    refactor: pass rooms to set_rooms by value

 fractal-gtk/src/appop/login.rs | 2 +-
 fractal-gtk/src/appop/mod.rs   | 2 +-
 fractal-gtk/src/appop/room.rs  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/fractal-gtk/src/appop/login.rs b/fractal-gtk/src/appop/login.rs
index ce959759..1e55ec7f 100644
--- a/fractal-gtk/src/appop/login.rs
+++ b/fractal-gtk/src/appop/login.rs
@@ -47,7 +47,7 @@ impl AppOp {
     }
 
     pub fn bk_logout(&mut self) {
-        self.set_rooms(&vec![], None);
+        self.set_rooms(vec![], None);
         if let Err(_) = cache::destroy() {
             error!("Error removing cache file");
         }
diff --git a/fractal-gtk/src/appop/mod.rs b/fractal-gtk/src/appop/mod.rs
index f6631bcf..34ca1986 100644
--- a/fractal-gtk/src/appop/mod.rs
+++ b/fractal-gtk/src/appop/mod.rs
@@ -117,7 +117,7 @@ impl AppOp {
 
         if let Ok(data) = cache::load() {
             let r: Vec<Room> = data.rooms.values().cloned().collect();
-            self.set_rooms(&r, None);
+            self.set_rooms(r, None);
             /* Make sure that since is never an empty string */
             self.since = data.since.filter(|s| !s.is_empty());
             self.username = Some(data.username);
diff --git a/fractal-gtk/src/appop/room.rs b/fractal-gtk/src/appop/room.rs
index a387084b..529c96cc 100644
--- a/fractal-gtk/src/appop/room.rs
+++ b/fractal-gtk/src/appop/room.rs
@@ -31,7 +31,6 @@ pub enum RoomPanel {
 impl AppOp {
     pub fn update_rooms(&mut self, rooms: Vec<Room>, default: Option<Room>) {
         let rs: Vec<Room> = rooms.iter().filter(|x| !x.left).cloned().collect();
-        self.set_rooms(&rs, default);
 
         // uploading each room avatar
         for r in rooms.iter() {
@@ -39,6 +38,7 @@ impl AppOp {
                 .send(BKCommand::GetRoomAvatar(r.id.clone()))
                 .unwrap();
         }
+        self.set_rooms(rs, default);
     }
 
     pub fn new_rooms(&mut self, rooms: Vec<Room>) {
@@ -71,7 +71,7 @@ impl AppOp {
         self.unsent_messages.remove(&id);
     }
 
-    pub fn set_rooms(&mut self, rooms: &Vec<Room>, def: Option<Room>) {
+    pub fn set_rooms(&mut self, rooms: Vec<Room>, def: Option<Room>) {
         let container: gtk::Box = self
             .ui
             .builder


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