Commit e49c770b3f

e49c770b3f7df1d3054c1238ed14ced8ec9338d9

parent: fafce3b6c5

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-10-10 15:24 UTC

room_buffer: Shorten some doc comments.

Layout: unified · split

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