-
Notifications
You must be signed in to change notification settings - Fork 35
Handle matrix.to room alias and room ID links. #531
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
24d8652
5462d28
fb40970
4017881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,14 +19,15 @@ use matrix_sdk_ui::timeline::{ | |||||
}; | ||||||
|
||||||
use crate::{ | ||||||
app::RoomsPanelRestoreAction, avatar_cache, event_preview::{plaintext_body_of_timeline_item, text_preview_of_encrypted_message, text_preview_of_member_profile_change, text_preview_of_other_state, text_preview_of_redacted_message, text_preview_of_room_membership_change, text_preview_of_timeline_item}, home::{edited_indicator::EditedIndicatorWidgetRefExt, editing_pane::EditingPaneState, loading_pane::{LoadingPaneState, LoadingPaneWidgetExt}, rooms_list::RoomsListRef}, location::init_location_subscriber, media_cache::{MediaCache, MediaCacheEntry}, profile::{ | ||||||
app::{RoomsPanelRestoreAction, SelectedRoom}, avatar_cache, event_preview::{plaintext_body_of_timeline_item, text_preview_of_encrypted_message, text_preview_of_member_profile_change, text_preview_of_other_state, text_preview_of_redacted_message, text_preview_of_room_membership_change, text_preview_of_timeline_item}, home::{edited_indicator::EditedIndicatorWidgetRefExt, editing_pane::EditingPaneState, loading_pane::{LoadingPaneState, LoadingPaneWidgetExt}, rooms_list::{RoomsListAction, RoomsListRef}}, location::init_location_subscriber, media_cache::{MediaCache, MediaCacheEntry}, profile::{ | ||||||
user_profile::{AvatarState, ShowUserProfileAction, UserProfile, UserProfileAndRoomId, UserProfilePaneInfo, UserProfileSlidingPaneRef, UserProfileSlidingPaneWidgetExt}, | ||||||
user_profile_cache, | ||||||
}, shared::{ | ||||||
avatar::AvatarWidgetRefExt, callout_tooltip::TooltipAction, html_or_plaintext::{HtmlOrPlaintextRef, HtmlOrPlaintextWidgetRefExt, RobrixHtmlLinkAction}, jump_to_bottom_button::{JumpToBottomButtonWidgetExt, UnreadMessageCount}, popup_list::{enqueue_popup_notification, PopupItem}, styles::COLOR_DANGER_RED, text_or_image::{TextOrImageRef, TextOrImageWidgetRefExt}, timestamp::TimestampWidgetRefExt, typing_animation::TypingAnimationWidgetExt | ||||||
}, sliding_sync::{get_client, submit_async_request, take_timeline_endpoints, BackwardsPaginateUntilEventRequest, MatrixRequest, PaginationDirection, TimelineRequestSender, UserPowerLevels}, utils::{self, room_name_or_id, unix_time_millis_to_datetime, ImageFormat, MEDIA_THUMBNAIL_FORMAT} | ||||||
}; | ||||||
use crate::home::event_reaction_list::ReactionListWidgetRefExt; | ||||||
use crate::room::ResolveRoomAliasAction; | ||||||
use crate::home::room_read_receipt::AvatarRowWidgetRefExt; | ||||||
use crate::room::room_input_bar::RoomInputBarWidgetExt; | ||||||
use crate::shared::mentionable_text_input::MentionableTextInputWidgetRefExt; | ||||||
|
@@ -995,6 +996,43 @@ impl Widget for RoomScreen { | |||||
); | ||||||
} | ||||||
} | ||||||
|
||||||
// Handle resolved room alias actions - only for requests from this widget | ||||||
if let Some(ResolveRoomAliasAction::Resolved { requester_uid, room_alias: _ , room_id, servers: _ }) = action.downcast_ref() { | ||||||
// Only handle this action if it was requested by this widget | ||||||
if *requester_uid == room_screen_widget_uid { | ||||||
|
||||||
if let Some(known_room) = get_client().and_then(|c| c.get_room(room_id)) { | ||||||
if known_room.is_space() { | ||||||
enqueue_popup_notification(PopupItem { | ||||||
message: format!("Found space {} but it is a space, not a regular room.", room_id), | ||||||
|
message: format!("Found space {} but it is a space, not a regular room.", room_id), | |
message: String::from("Showing a space's home page is not yet supported."), |
Outdated
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.
why are you assuming this is a joined room?
Outdated
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.
i dont understand this error condition. Why is it a problem that the room hasn't been joined yet? Can't you request a preview of non-joined rooms?
(Note that my comment that you removed also mentioned this. I believe that Client::get_room_preview()
will handle all of the cases here.)
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.
The only conditions we'd want to notify the user of are:
- an error if we cannot fetch the room preview
- a notice if the room exists but cannot be previewed and must be joined instead
Outdated
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.
how do you know the room is a Joined room here? what if it's an invite?
Outdated
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.
this is very expensive --- we cannot iterate over all rooms in the client on the main UI thread.
You deleted my comments, but those comments clearly stated what we needed to do. We do need to show a loading screen (like how I use the LoadingPane
widget when looking for an old replied-to message) while waiting on a background task to resolve the room alias. This is not optional, and I left the same comment on your previous PR on this topic.
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.
Recall that in general, we want to avoid doing as much work as possible on the main UI thread, and move as many things as possible to a background task/thread.
Outdated
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.
you're assuming this room has been joined again.
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.
you should use a match statement for all
ResolveRoomAliasAction
s, not multiple separateif let
blocks.