Set room only after project has been shared to avoid flicker
This commit is contained in:
+14
-12
@@ -50,9 +50,7 @@ impl ActiveCall {
|
|||||||
let room = if let Some(room) = room {
|
let room = if let Some(room) = room {
|
||||||
room
|
room
|
||||||
} else {
|
} else {
|
||||||
let room = cx.update(|cx| Room::create(client, user_store, cx)).await?;
|
cx.update(|cx| Room::create(client, user_store, cx)).await?
|
||||||
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx));
|
|
||||||
room
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let initial_project_id = if let Some(initial_project) = initial_project {
|
let initial_project_id = if let Some(initial_project) = initial_project {
|
||||||
@@ -65,6 +63,8 @@ impl ActiveCall {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.update(&mut cx, |this, cx| this.set_room(Some(room.clone()), cx));
|
||||||
room.update(&mut cx, |room, cx| {
|
room.update(&mut cx, |room, cx| {
|
||||||
room.call(recipient_user_id, initial_project_id, cx)
|
room.call(recipient_user_id, initial_project_id, cx)
|
||||||
})
|
})
|
||||||
@@ -88,16 +88,18 @@ impl ActiveCall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_room(&mut self, room: Option<ModelHandle<Room>>, cx: &mut ModelContext<Self>) {
|
fn set_room(&mut self, room: Option<ModelHandle<Room>>, cx: &mut ModelContext<Self>) {
|
||||||
if let Some(room) = room {
|
if room.as_ref() != self.room.as_ref().map(|room| &room.0) {
|
||||||
let subscriptions = vec![
|
if let Some(room) = room {
|
||||||
cx.observe(&room, |_, _, cx| cx.notify()),
|
let subscriptions = vec![
|
||||||
cx.subscribe(&room, |_, _, event, cx| cx.emit(event.clone())),
|
cx.observe(&room, |_, _, cx| cx.notify()),
|
||||||
];
|
cx.subscribe(&room, |_, _, event, cx| cx.emit(event.clone())),
|
||||||
self.room = Some((room, subscriptions));
|
];
|
||||||
} else {
|
self.room = Some((room, subscriptions));
|
||||||
self.room = None;
|
} else {
|
||||||
|
self.room = None;
|
||||||
|
}
|
||||||
|
cx.notify();
|
||||||
}
|
}
|
||||||
cx.notify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn room(&self) -> Option<&ModelHandle<Room>> {
|
pub fn room(&self) -> Option<&ModelHandle<Room>> {
|
||||||
|
|||||||
Reference in New Issue
Block a user