Commit e49c770b3f
Unsigned
Layout: unified · split
src/room_buffer.rs +19 −14
| @@ -412,7 +412,8 @@ impl RoomBuffer { | ||
| 412 | 412 | |
| 413 | 413 | /// Remove a Weechat room member by user ID. |
| 414 | 414 | /// |
| 415 | /// Returns either the removed Weechat room member, or an error if the member does not exist. | |
| 415 | /// Returns either the removed Weechat room member, or an error if the | |
| 416 | /// member does not exist. | |
| 416 | 417 | pub fn remove_member( |
| 417 | 418 | &mut self, |
| 418 | 419 | user_id: &UserId, |
| @@ -439,7 +440,8 @@ impl RoomBuffer { | ||
| 439 | 440 | |
| 440 | 441 | /// Change nick of member. |
| 441 | 442 | /// |
| 442 | /// Returns either the old nick of the member, or an error if the member does not exist. | |
| 443 | /// Returns either the old nick of the member, or an error if the member | |
| 444 | /// does not exist. | |
| 443 | 445 | pub fn rename_member( |
| 444 | 446 | &mut self, |
| 445 | 447 | user_id: &UserId, |
| @@ -499,10 +501,11 @@ impl RoomBuffer { | ||
| 499 | 501 | self.weechat_buffer().set_name(&name) |
| 500 | 502 | } |
| 501 | 503 | |
| 502 | /// Helper method to calculate the display name of a room member from their UserId. | |
| 504 | /// Helper method to calculate the display name of a room member from their | |
| 505 | /// UserId. | |
| 503 | 506 | /// |
| 504 | /// If no member with that ID is in the room, the string representation of the ID will be | |
| 505 | /// returned. | |
| 507 | /// If no member with that ID is in the room, the string representation of | |
| 508 | /// the ID will be returned. | |
| 506 | 509 | fn calculate_user_name(&self, user_id: &UserId) -> String { |
| 507 | 510 | self.room() |
| 508 | 511 | .get_member(user_id) |
| @@ -537,8 +540,8 @@ impl RoomBuffer { | ||
| 537 | 540 | let send = async move |typing: bool| { |
| 538 | 541 | let typing_time = typing_notice_time; |
| 539 | 542 | |
| 540 | // We're in the process of sending out a typing notice, so don't make | |
| 541 | // the same request twice. | |
| 543 | // We're in the process of sending out a typing notice, so don't | |
| 544 | // make the same request twice. | |
| 542 | 545 | let guard = match typing_in_flight.try_lock() { |
| 543 | 546 | Ok(guard) => guard, |
| 544 | 547 | Err(_) => { |
| @@ -593,8 +596,8 @@ impl RoomBuffer { | ||
| 593 | 596 | |
| 594 | 597 | /// Process disambiguations received from the SDK. |
| 595 | 598 | /// |
| 596 | /// Disambiguations are a hashmap of user ID -> bool indicating that this user is either newly | |
| 597 | /// ambiguous (true) or no longer ambiguous (false). | |
| 599 | /// Disambiguations are a hashmap of user ID -> bool indicating that this | |
| 600 | /// user is either newly ambiguous (true) or no longer ambiguous (false). | |
| 598 | 601 | #[allow(dead_code)] |
| 599 | 602 | fn process_disambiguations( |
| 600 | 603 | &mut self, |
| @@ -647,6 +650,7 @@ impl RoomBuffer { | ||
| 647 | 650 | ) { |
| 648 | 651 | let sender_id = event.sender.clone(); |
| 649 | 652 | let target_id; |
| 653 | ||
| 650 | 654 | if let Ok(t) = UserId::try_from(event.state_key.clone()) { |
| 651 | 655 | target_id = t; |
| 652 | 656 | } else { |
| @@ -664,9 +668,10 @@ impl RoomBuffer { | ||
| 664 | 668 | |
| 665 | 669 | // FIXME: Handle gaps (e.g. long disconnects) properly. |
| 666 | 670 | // |
| 667 | // For joins and invites, first we need to check whether a member with some MXID | |
| 668 | // exists. If he does, we have to update *that* member with the new state. Only if they | |
| 669 | // do not exist yet do we create a new one. | |
| 671 | // For joins and invites, first we need to check whether a member | |
| 672 | // with some MXID exists. If he does, we have to update *that* | |
| 673 | // member with the new state. Only if they do not exist yet do we | |
| 674 | // create a new one. | |
| 670 | 675 | // |
| 671 | 676 | // For leaves and bans we just need to remove the member. |
| 672 | 677 | match event.content.membership { |
| @@ -694,8 +699,8 @@ impl RoomBuffer { | ||
| 694 | 699 | // emitter. |
| 695 | 700 | // self.process_disambiguations(&disambiguations); |
| 696 | 701 | |
| 697 | // Names of rooms without display names can get affected by the member list so we need to | |
| 698 | // update them. | |
| 702 | // Names of rooms without display names can get affected by the | |
| 703 | // member list so we need to update them. | |
| 699 | 704 | self.update_buffer_name(); |
| 700 | 705 | } else { |
| 701 | 706 | let change_op = event.membership_change(); |