Commit 8454dcd167
8454dcd1674dfb48ab4ee615134e2d4d5fc04fa7
parent: 80ccd863a0
Unsigned
Darafei Praliaskouski <me@komzpa.net> · 2026-07-26 08:12 UTC
committer: <strk@kbt.io>
fix: close thread buffer on part
Layout: unified · split
src/commands/part.rs
+4
| @@ -31,6 +31,10 @@ impl CommandRunCallback for PartCommand { |
| 31 | _: Cow<str>, |
31 | _: Cow<str>, |
| 32 | ) -> ReturnCode { |
32 | ) -> ReturnCode { |
| 33 | if let Some(room) = self.servers.find_room(buffer) { |
33 | if let Some(room) = self.servers.find_room(buffer) { |
| |
34 | if room.close_thread_buffer(buffer) { |
| |
35 | return ReturnCode::OkEat; |
| |
36 | } |
| |
37 | |
| 34 | Weechat::spawn(async move { room.leave().await }).detach(); |
38 | Weechat::spawn(async move { room.leave().await }).detach(); |
| 35 | |
39 | |
| 36 | ReturnCode::OkEat |
40 | ReturnCode::OkEat |
src/room/buffer.rs
+26
| @@ -70,6 +70,21 @@ impl RoomBuffer { |
| 70 | .any(|handle| handle.upgrade().is_ok_and(|b| &b == buffer)) |
70 | .any(|handle| handle.upgrade().is_ok_and(|b| &b == buffer)) |
| 71 | } |
71 | } |
| 72 | |
72 | |
| |
73 | pub fn thread_root_for_buffer( |
| |
74 | &self, |
| |
75 | buffer: &Buffer, |
| |
76 | ) -> Option<OwnedEventId> { |
| |
77 | self.thread_buffers |
| |
78 | .borrow() |
| |
79 | .iter() |
| |
80 | .find_map(|(thread_root, handle)| { |
| |
81 | handle |
| |
82 | .upgrade() |
| |
83 | .is_ok_and(|b| &b == buffer) |
| |
84 | .then(|| thread_root.clone()) |
| |
85 | }) |
| |
86 | } |
| |
87 | |
| 73 | pub fn thread_buffer(&self, thread_root: &EventId) -> Option<BufferHandle> { |
88 | pub fn thread_buffer(&self, thread_root: &EventId) -> Option<BufferHandle> { |
| 74 | self.thread_buffers.borrow().get(thread_root).cloned() |
89 | self.thread_buffers.borrow().get(thread_root).cloned() |
| 75 | } |
90 | } |
| @@ -86,6 +101,17 @@ impl RoomBuffer { |
| 86 | self.thread_buffers.borrow_mut().remove(thread_root); |
101 | self.thread_buffers.borrow_mut().remove(thread_root); |
| 87 | } |
102 | } |
| 88 | |
103 | |
| |
104 | pub fn remove_thread_buffer_for_buffer(&self, buffer: &Buffer) -> bool { |
| |
105 | let thread_root = self.thread_root_for_buffer(buffer); |
| |
106 | |
| |
107 | if let Some(thread_root) = thread_root { |
| |
108 | self.remove_thread_buffer(&thread_root); |
| |
109 | true |
| |
110 | } else { |
| |
111 | false |
| |
112 | } |
| |
113 | } |
| |
114 | |
| 89 | /// Return the sender ID for an event that is still in the buffer. |
115 | /// Return the sender ID for an event that is still in the buffer. |
| 90 | /// |
116 | /// |
| 91 | /// Reply rendering uses this local lookup so it never blocks on a |
117 | /// Reply rendering uses this local lookup so it never blocks on a |
src/room/mod.rs
+9
| @@ -530,6 +530,15 @@ impl MatrixRoom { |
| 530 | self.buffer.owns_buffer(buffer) |
530 | self.buffer.owns_buffer(buffer) |
| 531 | } |
531 | } |
| 532 | |
532 | |
| |
533 | pub fn close_thread_buffer(&self, buffer: &Buffer) -> bool { |
| |
534 | if self.buffer.remove_thread_buffer_for_buffer(buffer) { |
| |
535 | buffer.close(); |
| |
536 | true |
| |
537 | } else { |
| |
538 | false |
| |
539 | } |
| |
540 | } |
| |
541 | |
| 533 | pub fn release_sdk_state(&self) { |
542 | pub fn release_sdk_state(&self) { |
| 534 | self.verification.release_sdk_state(); |
543 | self.verification.release_sdk_state(); |
| 535 | self.room.borrow_mut().take(); |
544 | self.room.borrow_mut().take(); |