collab: Reconnect to channel notes (#31950)
Closes #31758 Release Notes: - Fixed channel notes not getting re-connected when a connection to Zed servers is restored. --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
parent
b820aa1fcd
commit
a60bea8a3d
3 changed files with 19 additions and 2 deletions
|
@ -35,6 +35,7 @@ pub struct ChannelBuffer {
|
||||||
pub enum ChannelBufferEvent {
|
pub enum ChannelBufferEvent {
|
||||||
CollaboratorsChanged,
|
CollaboratorsChanged,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
|
Connected,
|
||||||
BufferEdited,
|
BufferEdited,
|
||||||
ChannelChanged,
|
ChannelChanged,
|
||||||
}
|
}
|
||||||
|
@ -103,6 +104,17 @@ impl ChannelBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn connected(&mut self, cx: &mut Context<Self>) {
|
||||||
|
self.connected = true;
|
||||||
|
if self.subscription.is_none() {
|
||||||
|
let Ok(subscription) = self.client.subscribe_to_entity(self.channel_id.0) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
self.subscription = Some(subscription.set_entity(&cx.entity(), &mut cx.to_async()));
|
||||||
|
cx.emit(ChannelBufferEvent::Connected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn remote_id(&self, cx: &App) -> BufferId {
|
pub fn remote_id(&self, cx: &App) -> BufferId {
|
||||||
self.buffer.read(cx).remote_id()
|
self.buffer.read(cx).remote_id()
|
||||||
}
|
}
|
||||||
|
|
|
@ -972,6 +972,7 @@ impl ChannelStore {
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
if let Some(operations) = operations {
|
if let Some(operations) = operations {
|
||||||
|
channel_buffer.connected(cx);
|
||||||
let client = this.client.clone();
|
let client = this.client.clone();
|
||||||
cx.background_spawn(async move {
|
cx.background_spawn(async move {
|
||||||
let operations = operations.await;
|
let operations = operations.await;
|
||||||
|
@ -1012,8 +1013,8 @@ impl ChannelStore {
|
||||||
|
|
||||||
if let Some(this) = this.upgrade() {
|
if let Some(this) = this.upgrade() {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
for (_, buffer) in this.opened_buffers.drain() {
|
for (_, buffer) in &this.opened_buffers {
|
||||||
if let OpenEntityHandle::Open(buffer) = buffer {
|
if let OpenEntityHandle::Open(buffer) = &buffer {
|
||||||
if let Some(buffer) = buffer.upgrade() {
|
if let Some(buffer) = buffer.upgrade() {
|
||||||
buffer.update(cx, |buffer, cx| buffer.disconnect(cx));
|
buffer.update(cx, |buffer, cx| buffer.disconnect(cx));
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,6 +354,10 @@ impl ChannelView {
|
||||||
editor.set_read_only(true);
|
editor.set_read_only(true);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}),
|
}),
|
||||||
|
ChannelBufferEvent::Connected => self.editor.update(cx, |editor, cx| {
|
||||||
|
editor.set_read_only(false);
|
||||||
|
cx.notify();
|
||||||
|
}),
|
||||||
ChannelBufferEvent::ChannelChanged => {
|
ChannelBufferEvent::ChannelChanged => {
|
||||||
self.editor.update(cx, |_, cx| {
|
self.editor.update(cx, |_, cx| {
|
||||||
cx.emit(editor::EditorEvent::TitleChanged);
|
cx.emit(editor::EditorEvent::TitleChanged);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue