Change channel join behavior
- Clicking on a channel name now joins the channel if you are not in it - (or opens the notes if you are already there). - When joining a channel, previously shared projects are opened automatically. - If there are no previously shared projects, the notes are opened.
This commit is contained in:
parent
d9813a5bec
commit
18e7305b6d
3 changed files with 74 additions and 10 deletions
|
@ -291,10 +291,10 @@ impl ActiveCall {
|
|||
&mut self,
|
||||
channel_id: u64,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<()>> {
|
||||
) -> Task<Result<ModelHandle<Room>>> {
|
||||
if let Some(room) = self.room().cloned() {
|
||||
if room.read(cx).channel_id() == Some(channel_id) {
|
||||
return Task::ready(Ok(()));
|
||||
return Task::ready(Ok(room));
|
||||
} else {
|
||||
room.update(cx, |room, cx| room.clear_state(cx));
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ impl ActiveCall {
|
|||
this.update(&mut cx, |this, cx| {
|
||||
this.report_call_event("join channel", cx)
|
||||
});
|
||||
Ok(())
|
||||
Ok(room)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -594,6 +594,33 @@ impl Room {
|
|||
.map_or(&[], |v| v.as_slice())
|
||||
}
|
||||
|
||||
/// projects_to_join returns a list of shared projects sorted such
|
||||
/// that the most 'active' projects appear last.
|
||||
pub fn projects_to_join(&self) -> Vec<(u64, u64)> {
|
||||
let mut projects = HashMap::default();
|
||||
let mut hosts = HashMap::default();
|
||||
for participant in self.remote_participants.values() {
|
||||
match participant.location {
|
||||
ParticipantLocation::SharedProject { project_id } => {
|
||||
*projects.entry(project_id).or_insert(0) += 1;
|
||||
}
|
||||
ParticipantLocation::External | ParticipantLocation::UnsharedProject => {}
|
||||
}
|
||||
for project in &participant.projects {
|
||||
*projects.entry(project.id).or_insert(0) += 1;
|
||||
hosts.insert(project.id, participant.user.id);
|
||||
}
|
||||
}
|
||||
|
||||
let mut pairs: Vec<(u64, usize)> = projects.into_iter().collect();
|
||||
pairs.sort_by_key(|(_, count)| 0 - *count as i32);
|
||||
|
||||
pairs
|
||||
.into_iter()
|
||||
.map(|(project_id, _)| (project_id, hosts[&project_id]))
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn handle_room_updated(
|
||||
this: ModelHandle<Self>,
|
||||
envelope: TypedEnvelope<proto::RoomUpdated>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue