[fractal/sync-matrix-sdk: 74/75] Make join_to_room shareable, mutable and sync
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/sync-matrix-sdk: 74/75] Make join_to_room shareable, mutable and sync
- Date: Tue, 2 Feb 2021 22:47:07 +0000 (UTC)
commit bc47c2145690189ee2e851e3d3757080cf553803
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Wed Dec 2 18:29:04 2020 +0100
Make join_to_room shareable, mutable and sync
fractal-gtk/src/appop/mod.rs | 4 ++--
fractal-gtk/src/appop/room.rs | 2 +-
fractal-gtk/src/appop/sync.rs | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/fractal-gtk/src/appop/mod.rs b/fractal-gtk/src/appop/mod.rs
index 134d6235..f85db92e 100644
--- a/fractal-gtk/src/appop/mod.rs
+++ b/fractal-gtk/src/appop/mod.rs
@@ -86,7 +86,7 @@ pub struct AppOp {
pub login_data: Option<LoginData>,
pub active_room: Option<RoomId>,
- pub join_to_room: Option<RoomId>,
+ pub join_to_room: Arc<Mutex<Option<RoomId>>>,
pub rooms: RoomList,
unread_rooms: usize,
pub unsent_messages: HashMap<RoomId, (String, i32)>,
@@ -111,7 +111,7 @@ impl AppOp {
app_runtime,
ui,
active_room: None,
- join_to_room: None,
+ join_to_room: Arc::new(Mutex::new(None)),
rooms: HashMap::new(),
login_data: None,
syncing: false,
diff --git a/fractal-gtk/src/appop/room.rs b/fractal-gtk/src/appop/room.rs
index 9002b821..773df579 100644
--- a/fractal-gtk/src/appop/room.rs
+++ b/fractal-gtk/src/appop/room.rs
@@ -174,7 +174,7 @@ impl AppOp {
}
pub fn set_join_to_room(&mut self, jtr: Option<RoomId>) {
- self.join_to_room = jtr;
+ *self.join_to_room.lock().unwrap() = jtr;
}
pub fn set_active_room_by_id(&mut self, id: RoomId) {
diff --git a/fractal-gtk/src/appop/sync.rs b/fractal-gtk/src/appop/sync.rs
index 82ef00d5..a29ef4fd 100644
--- a/fractal-gtk/src/appop/sync.rs
+++ b/fractal-gtk/src/appop/sync.rs
@@ -95,11 +95,11 @@ impl AppOp {
}
} else {
let rooms = sync_ret.rooms;
- let jtr = join_to_room.and_then(|jtr| {
+ let jtr = join_to_room.lock().unwrap().as_ref().and_then(|jtr| {
rooms
.iter()
.map(|room| &room.id)
- .find(|rid| **rid == jtr)
+ .find(|rid| *rid == jtr)
.cloned()
});
APPOP!(set_rooms, (rooms, clear_room_list));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]