Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Avoid leak of channel store
Max Brunsfeld498d043a0af2
diff --git a/crates/client/src/channel_store.rs b/crates/client/src/channel_store.rsindex ec945ce0367..8fb005a2628 100644--- a/crates/client/src/channel_store.rs+++ b/crates/client/src/channel_store.rs@@ -58,16 +58,20 @@ impl ChannelStore {client.add_message_handler(cx.handle(), Self::handle_update_channels);let mut current_user = user_store.read(cx).watch_current_user();- let maintain_user = cx.spawn(|this, mut cx| async move {+ let maintain_user = cx.spawn_weak(|this, mut cx| async move {while let Some(current_user) = current_user.next().await {if current_user.is_none() {- this.update(&mut cx, |this, cx| {- this.channels.clear();- this.channel_invitations.clear();- this.channel_participants.clear();- this.outgoing_invites.clear();- cx.notify();- });+ if let Some(this) = this.upgrade(&cx) {+ this.update(&mut cx, |this, cx| {+ this.channels.clear();+ this.channel_invitations.clear();+ this.channel_participants.clear();+ this.outgoing_invites.clear();+ cx.notify();+ });+ } else {+ break;+ }}}});