-
Notifications
You must be signed in to change notification settings - Fork 37
Use RoomDisplayName everywhere to ensure that room names display correctly
#590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TigerInYourDream
wants to merge
10
commits into
project-robius:main
Choose a base branch
from
TigerInYourDream:fix/invited-room-name-display
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+355
−129
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
612a10e
Fix room name display issues for invited rooms and newly joined rooms
TigerInYourDream 5d5fc90
Merge branch 'main' into fix/invited-room-name-display
TigerInYourDream b46f56f
Remove preferred_room_name and use RoomDisplayName directly
TigerInYourDream b7dbaef
Fix invite room display names when Enum and remove untils funtions
TigerInYourDream 61884de
Merge branch 'main' into fix/invited-room-name-display
TigerInYourDream fe256a7
Merge branch 'main' into fix/invited-room-name-display
TigerInYourDream 8178e6c
update RoomName instead of RoomNameRon
TigerInYourDream 2346237
Update room name handling
TigerInYourDream 6e3774b
Merge branch 'main' into fix/invited-room-name-display
TigerInYourDream 386df39
clean code
TigerInYourDream File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,12 @@ | ||||||
| use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc}; | ||||||
| use crossbeam_queue::SegQueue; | ||||||
| use makepad_widgets::*; | ||||||
| use matrix_sdk::{ruma::{events::tag::Tags, MilliSecondsSinceUnixEpoch, OwnedRoomAliasId, OwnedRoomId, OwnedUserId}, RoomState}; | ||||||
| use matrix_sdk::{RoomDisplayName, ruma::{events::tag::Tags, MilliSecondsSinceUnixEpoch, OwnedRoomAliasId, OwnedRoomId, OwnedUserId}, RoomState}; | ||||||
| use crate::{ | ||||||
| app::{AppState, SelectedRoom}, | ||||||
| room::{room_display_filter::{RoomDisplayFilter, RoomDisplayFilterBuilder, RoomFilterCriteria, SortFn}, RoomPreviewAvatar}, | ||||||
| shared::{collapsible_header::{CollapsibleHeaderAction, CollapsibleHeaderWidgetRefExt, HeaderCategory}, jump_to_bottom_button::UnreadMessageCount, popup_list::{enqueue_popup_notification, PopupItem, PopupKind}, room_filter_input_bar::RoomFilterAction}, | ||||||
| sliding_sync::{submit_async_request, MatrixRequest, PaginationDirection}, utils::room_name_or_id, | ||||||
| sliding_sync::{submit_async_request, MatrixRequest, PaginationDirection}, utils::display_name_with_fallback, | ||||||
| }; | ||||||
| use super::room_preview::RoomPreviewAction; | ||||||
|
|
||||||
|
|
@@ -132,7 +132,7 @@ pub enum RoomsListUpdate { | |||||
| /// Update the displayable name for the given room. | ||||||
| UpdateRoomName { | ||||||
| room_id: OwnedRoomId, | ||||||
| new_room_name: Option<String>, | ||||||
| new_room_name: RoomDisplayName, | ||||||
| }, | ||||||
| /// Update the avatar (image) for the given room. | ||||||
| UpdateRoomAvatar { | ||||||
|
|
@@ -201,7 +201,7 @@ pub struct JoinedRoomInfo { | |||||
| /// The matrix ID of this room. | ||||||
| pub room_id: OwnedRoomId, | ||||||
| /// The displayable name of this room, if known. | ||||||
| pub room_name: Option<String>, | ||||||
| pub room_name: RoomDisplayName, | ||||||
| /// The number of unread messages in this room. | ||||||
| pub num_unread_messages: u64, | ||||||
| /// The number of unread mentions in this room. | ||||||
|
|
@@ -240,7 +240,7 @@ pub struct InvitedRoomInfo { | |||||
| /// The matrix ID of this room. | ||||||
| pub room_id: OwnedRoomId, | ||||||
| /// The displayable name of this room, if known. | ||||||
| pub room_name: Option<String>, | ||||||
| pub room_name: RoomDisplayName, | ||||||
| /// The canonical alias for this room, if any. | ||||||
| pub canonical_alias: Option<OwnedRoomAliasId>, | ||||||
| /// The alternative aliases for this room, if any. | ||||||
|
|
@@ -399,7 +399,6 @@ impl RoomsList { | |||||
| RoomsListUpdate::AddJoinedRoom(joined_room) => { | ||||||
| let room_id = joined_room.room_id.clone(); | ||||||
| let is_direct = joined_room.is_direct; | ||||||
| let room_name = joined_room.room_name.clone(); | ||||||
| let should_display = (self.display_filter)(&joined_room); | ||||||
| let replaced = self.all_joined_rooms.insert(room_id.clone(), joined_room); | ||||||
| if replaced.is_none() { | ||||||
|
|
@@ -425,10 +424,19 @@ impl RoomsList { | |||||
| self.displayed_invited_rooms.iter() | ||||||
| .position(|r| r == &room_id) | ||||||
| .map(|index| self.displayed_invited_rooms.remove(index)); | ||||||
| let new_room_name = self.all_joined_rooms.get(&room_id).map(|room| display_name_with_fallback( | ||||||
| &room.room_name, | ||||||
| room.canonical_alias.as_ref(), | ||||||
| &room.alt_aliases, | ||||||
| &room.room_id, | ||||||
| )); | ||||||
| cx.widget_action( | ||||||
| self.widget_uid(), | ||||||
| &scope.path, | ||||||
| RoomsListAction::InviteAccepted { room_id, room_name } | ||||||
| RoomsListAction::InviteAccepted { | ||||||
| room_id: room_id.clone(), | ||||||
| room_name: new_room_name, | ||||||
| } | ||||||
| ); | ||||||
| } | ||||||
| self.update_status_rooms_count(); | ||||||
|
|
@@ -460,9 +468,11 @@ impl RoomsList { | |||||
| } | ||||||
| } | ||||||
| RoomsListUpdate::UpdateRoomName { room_id, new_room_name } => { | ||||||
| // Try to update joined room first | ||||||
| if let Some(room) = self.all_joined_rooms.get_mut(&room_id) { | ||||||
| let was_displayed = (self.display_filter)(room); | ||||||
| room.room_name = new_room_name; | ||||||
| // Keep the full RoomDisplayName to preserve EmptyWas semantics | ||||||
| room.room_name = new_room_name.clone(); | ||||||
| let should_display = (self.display_filter)(room); | ||||||
| match (was_displayed, should_display) { | ||||||
| // No need to update the displayed rooms list. | ||||||
|
|
@@ -482,24 +492,53 @@ impl RoomsList { | |||||
| // Room was not displayed but should now be displayed. | ||||||
| (false, true) => { | ||||||
| if room.is_direct { | ||||||
| self.displayed_direct_rooms.push(room_id); | ||||||
| self.displayed_direct_rooms.push(room_id.clone()); | ||||||
| } else { | ||||||
| self.displayed_regular_rooms.push(room_id); | ||||||
| self.displayed_regular_rooms.push(room_id.clone()); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } else { | ||||||
| error!("Error: couldn't find room {room_id} to update room name"); | ||||||
| } | ||||||
| // If not a joined room, try to update invited room | ||||||
| else { | ||||||
| let invited_rooms_ref = get_invited_rooms(cx); | ||||||
| let mut invited_rooms = invited_rooms_ref.borrow_mut(); | ||||||
| if let Some(invited_room) = invited_rooms.get_mut(&room_id) { | ||||||
| let was_displayed = (self.display_filter)(invited_room); | ||||||
| invited_room.room_name = new_room_name; | ||||||
| let should_display = (self.display_filter)(invited_room); | ||||||
| match (was_displayed, should_display) { | ||||||
| (true, true) | (false, false) => { } | ||||||
| (true, false) => { | ||||||
| self.displayed_invited_rooms.iter() | ||||||
| .position(|r| r == &room_id) | ||||||
| .map(|index| self.displayed_invited_rooms.remove(index)); | ||||||
| } | ||||||
| (false, true) => { | ||||||
| if !self.displayed_invited_rooms.contains(&room_id) { | ||||||
| self.displayed_invited_rooms.push(room_id.clone()); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } else { | ||||||
| warning!("Warning: couldn't find invited room {} to update room name", room_id); | ||||||
|
||||||
| warning!("Warning: couldn't find invited room {} to update room name", room_id); | |
| warning!("couldn't find invited room {} to update room name", room_id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'EmptyWas' to 'Empty' (likely meant to say 'Empty semantics' or reference a specific variant).