mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Don't return channels that were released in ChannelList::get_channel
This commit is contained in:
parent
4876e40a98
commit
836b6dfbaf
1 changed files with 10 additions and 19 deletions
|
@ -10,7 +10,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use postage::prelude::Stream;
|
use postage::prelude::Stream;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map, HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
ops::Range,
|
ops::Range,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
@ -139,25 +139,16 @@ impl ChannelList {
|
||||||
id: u64,
|
id: u64,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut MutableAppContext,
|
||||||
) -> Option<ModelHandle<Channel>> {
|
) -> Option<ModelHandle<Channel>> {
|
||||||
match self.channels.entry(id) {
|
if let Some(channel) = self.channels.get(&id).and_then(|c| c.upgrade(cx)) {
|
||||||
hash_map::Entry::Occupied(entry) => entry.get().upgrade(cx),
|
return Some(channel);
|
||||||
hash_map::Entry::Vacant(entry) => {
|
}
|
||||||
if let Some(details) = self
|
|
||||||
.available_channels
|
let channels = self.available_channels.as_ref()?;
|
||||||
.as_ref()
|
let details = channels.iter().find(|details| details.id == id)?.clone();
|
||||||
.and_then(|channels| channels.iter().find(|details| details.id == id))
|
|
||||||
{
|
|
||||||
let user_store = self.user_store.clone();
|
|
||||||
let rpc = self.rpc.clone();
|
|
||||||
let channel =
|
let channel =
|
||||||
cx.add_model(|cx| Channel::new(details.clone(), user_store, rpc, cx));
|
cx.add_model(|cx| Channel::new(details, self.user_store.clone(), self.rpc.clone(), cx));
|
||||||
entry.insert(channel.downgrade());
|
self.channels.insert(id, channel.downgrade());
|
||||||
Some(channel)
|
Some(channel)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue