Commit e325036526
Unsigned
Layout: unified · split
src/room_buffer.rs +6 −8
| @@ -70,7 +70,6 @@ use weechat::{ | |||
| 70 | 70 | ||
| 71 | #[derive(Clone)] | 71 | #[derive(Clone)] |
| 72 | pub struct RoomBuffer { | 72 | pub struct RoomBuffer { |
| 73 | typing_in_flight: Rc<Mutex<()>>, | ||
| 74 | inner: MatrixRoom, | 73 | inner: MatrixRoom, |
| 75 | buffer_handle: BufferHandle, | 74 | buffer_handle: BufferHandle, |
| 76 | } | 75 | } |
| @@ -90,11 +89,14 @@ pub enum RoomError { | |||
| 90 | 89 | ||
| 91 | #[derive(Clone)] | 90 | #[derive(Clone)] |
| 92 | pub struct MatrixRoom { | 91 | pub struct MatrixRoom { |
| 93 | server_name: Rc<String>, | ||
| 94 | homeserver: Rc<Url>, | 92 | homeserver: Rc<Url>, |
| 95 | room_id: Rc<RoomId>, | 93 | room_id: Rc<RoomId>, |
| 94 | |||
| 96 | connection: Rc<RefCell<Option<Connection>>>, | 95 | connection: Rc<RefCell<Option<Connection>>>, |
| 96 | |||
| 97 | typing_notice_time: Rc<RefCell<Option<Instant>>>, | 97 | typing_notice_time: Rc<RefCell<Option<Instant>>>, |
| 98 | typing_in_flight: Rc<Mutex<()>>, | ||
| 99 | |||
| 98 | room: Rc<RefCell<Room>>, | 100 | room: Rc<RefCell<Room>>, |
| 99 | members: HashMap<UserId, WeechatRoomMember>, | 101 | members: HashMap<UserId, WeechatRoomMember>, |
| 100 | } | 102 | } |
| @@ -134,18 +136,17 @@ impl MatrixRoom { | |||
| 134 | 136 | ||
| 135 | impl RoomBuffer { | 137 | impl RoomBuffer { |
| 136 | pub fn new( | 138 | pub fn new( |
| 137 | server_name: &str, | ||
| 138 | connection: &Rc<RefCell<Option<Connection>>>, | 139 | connection: &Rc<RefCell<Option<Connection>>>, |
| 139 | homeserver: &Url, | 140 | homeserver: &Url, |
| 140 | room_id: RoomId, | 141 | room_id: RoomId, |
| 141 | own_user_id: &UserId, | 142 | own_user_id: &UserId, |
| 142 | ) -> Self { | 143 | ) -> Self { |
| 143 | let room = MatrixRoom { | 144 | let room = MatrixRoom { |
| 144 | server_name: Rc::new(server_name.to_owned()), | ||
| 145 | homeserver: Rc::new(homeserver.clone()), | 145 | homeserver: Rc::new(homeserver.clone()), |
| 146 | room_id: Rc::new(room_id.clone()), | 146 | room_id: Rc::new(room_id.clone()), |
| 147 | connection: connection.clone(), | 147 | connection: connection.clone(), |
| 148 | typing_notice_time: Rc::new(RefCell::new(None)), | 148 | typing_notice_time: Rc::new(RefCell::new(None)), |
| 149 | typing_in_flight: Rc::new(Mutex::new(())), | ||
| 149 | room: Rc::new(RefCell::new(Room::new(&room_id, &own_user_id))), | 150 | room: Rc::new(RefCell::new(Room::new(&room_id, &own_user_id))), |
| 150 | members: HashMap::new(), | 151 | members: HashMap::new(), |
| 151 | }; | 152 | }; |
| @@ -167,7 +168,6 @@ impl RoomBuffer { | |||
| 167 | buffer.enable_nicklist(); | 168 | buffer.enable_nicklist(); |
| 168 | 169 | ||
| 169 | RoomBuffer { | 170 | RoomBuffer { |
| 170 | typing_in_flight: Rc::new(Mutex::new(())), | ||
| 171 | inner: room, | 171 | inner: room, |
| 172 | buffer_handle, | 172 | buffer_handle, |
| 173 | } | 173 | } |
| @@ -175,12 +175,10 @@ impl RoomBuffer { | |||
| 175 | 175 | ||
| 176 | pub fn restore( | 176 | pub fn restore( |
| 177 | room: Room, | 177 | room: Room, |
| 178 | server_name: &str, | ||
| 179 | connection: &Rc<RefCell<Option<Connection>>>, | 178 | connection: &Rc<RefCell<Option<Connection>>>, |
| 180 | homeserver: &Url, | 179 | homeserver: &Url, |
| 181 | ) -> Self { | 180 | ) -> Self { |
| 182 | let mut room_buffer = RoomBuffer::new( | 181 | let mut room_buffer = RoomBuffer::new( |
| 183 | server_name, | ||
| 184 | connection, | 182 | connection, |
| 185 | homeserver, | 183 | homeserver, |
| 186 | room.room_id.clone(), | 184 | room.room_id.clone(), |
| @@ -390,7 +388,7 @@ impl RoomBuffer { | |||
| 390 | /// | 388 | /// |
| 391 | /// If the input is empty the typing notice is disabled. | 389 | /// If the input is empty the typing notice is disabled. |
| 392 | pub fn update_typing_notice(&self) { | 390 | pub fn update_typing_notice(&self) { |
| 393 | let typing_in_flight = self.typing_in_flight.clone(); | 391 | let typing_in_flight = self.inner.typing_in_flight.clone(); |
| 394 | let buffer = self.weechat_buffer(); | 392 | let buffer = self.weechat_buffer(); |
| 395 | let input = buffer.input(); | 393 | let input = buffer.input(); |
| 396 | 394 | ||
src/server.rs −2
| @@ -550,7 +550,6 @@ impl InnerServer { | |||
| 550 | .as_ref() | 550 | .as_ref() |
| 551 | .expect("Receiving events while not being logged in"); | 551 | .expect("Receiving events while not being logged in"); |
| 552 | let buffer = RoomBuffer::new( | 552 | let buffer = RoomBuffer::new( |
| 553 | &self.server_name, | ||
| 554 | &self.connection, | 553 | &self.connection, |
| 555 | homeserver, | 554 | homeserver, |
| 556 | room_id.clone(), | 555 | room_id.clone(), |
| @@ -585,7 +584,6 @@ impl InnerServer { | |||
| 585 | 584 | ||
| 586 | let buffer = RoomBuffer::restore( | 585 | let buffer = RoomBuffer::restore( |
| 587 | room, | 586 | room, |
| 588 | &self.server_name, | ||
| 589 | &self.connection, | 587 | &self.connection, |
| 590 | homeserver, | 588 | homeserver, |
| 591 | ); | 589 | ); |