@@ -7,34 +7,32 @@ use bytesize::ByteSize;
77use imbl:: Vector ;
88use makepad_widgets:: { image_cache:: ImageBuffer , * } ;
99use matrix_sdk:: {
10- room:: RoomMember , ruma:: {
11- events:: {
10+ OwnedServerName , RoomState , room:: RoomMember , ruma:: {
11+ EventId , MatrixToUri , MatrixUri , OwnedEventId , OwnedMxcUri , OwnedRoomId , UserId , events:: {
1212 receipt:: Receipt ,
1313 room:: {
14- message:: {
14+ ImageInfo , MediaSource , message:: {
1515 AudioMessageEventContent , EmoteMessageEventContent , FileMessageEventContent , FormattedBody , ImageMessageEventContent , KeyVerificationRequestEventContent , LocationMessageEventContent , MessageFormat , MessageType , NoticeMessageEventContent , TextMessageEventContent , VideoMessageEventContent
16- } ,
17- ImageInfo , MediaSource
16+ }
1817 } ,
1918 sticker:: { StickerEventContent , StickerMediaSource } ,
20- } ,
21- matrix_uri:: MatrixId , uint, EventId , MatrixToUri , MatrixUri , OwnedEventId , OwnedMxcUri , OwnedRoomId , UserId
22- } , OwnedServerName
19+ } , matrix_uri:: MatrixId , uint
20+ }
2321} ;
2422use matrix_sdk_ui:: timeline:: {
2523 self , EmbeddedEvent , EncryptedMessage , EventTimelineItem , InReplyToDetails , MemberProfileChange , MsgLikeContent , MsgLikeKind , OtherMessageLike , PollState , RoomMembershipChange , TimelineDetails , TimelineEventItemId , TimelineItem , TimelineItemContent , TimelineItemKind , VirtualTimelineItem
2624} ;
2725
2826use crate :: {
29- app:: AppStateAction , avatar_cache, event_preview:: { plaintext_body_of_timeline_item, text_preview_of_encrypted_message, text_preview_of_member_profile_change, text_preview_of_other_message_like, 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 , link_preview:: { LinkPreviewCache , LinkPreviewRef , LinkPreviewWidgetRefExt } , loading_pane:: { LoadingPaneState , LoadingPaneWidgetExt } , rooms_list:: RoomsListRef , tombstone_footer:: SuccessorRoomDetails } , media_cache:: { MediaCache , MediaCacheEntry } , profile:: {
27+ app:: { AppStateAction , 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_message_like, 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 , link_preview:: { LinkPreviewCache , LinkPreviewRef , LinkPreviewWidgetRefExt } , loading_pane:: { LoadingPaneState , LoadingPaneWidgetExt } , rooms_list:: { RoomsListAction , RoomsListRef } , tombstone_footer:: SuccessorRoomDetails } , media_cache:: { MediaCache , MediaCacheEntry } , profile:: {
3028 user_profile:: { AvatarState , ShowUserProfileAction , UserProfile , UserProfileAndRoomId , UserProfilePaneInfo , UserProfileSlidingPaneRef , UserProfileSlidingPaneWidgetExt } ,
3129 user_profile_cache,
3230 } ,
3331 room:: { room_input_bar:: RoomInputBarState , typing_notice:: TypingNoticeWidgetExt } ,
3432 shared:: {
35- avatar:: AvatarWidgetRefExt , callout_tooltip:: TooltipAction , html_or_plaintext:: { HtmlOrPlaintextRef , HtmlOrPlaintextWidgetRefExt , RobrixHtmlLinkAction } , jump_to_bottom_button:: { JumpToBottomButtonWidgetExt , UnreadMessageCount } , popup_list:: { enqueue_popup_notification , PopupItem , PopupKind } , restore_status_view:: RestoreStatusViewWidgetExt , styles:: * , text_or_image:: { TextOrImageRef , TextOrImageWidgetRefExt } , timestamp:: TimestampWidgetRefExt
33+ avatar:: AvatarWidgetRefExt , callout_tooltip:: TooltipAction , html_or_plaintext:: { HtmlOrPlaintextRef , HtmlOrPlaintextWidgetRefExt , RobrixHtmlLinkAction } , jump_to_bottom_button:: { JumpToBottomButtonWidgetExt , UnreadMessageCount } , popup_list:: { PopupItem , PopupKind , enqueue_popup_notification } , restore_status_view:: RestoreStatusViewWidgetExt , styles:: * , text_or_image:: { TextOrImageRef , TextOrImageWidgetRefExt } , timestamp:: TimestampWidgetRefExt
3634 } ,
37- sliding_sync:: { get_client , submit_async_request , take_timeline_endpoints , BackwardsPaginateUntilEventRequest , MatrixRequest , PaginationDirection , TimelineEndpoints , TimelineRequestSender , UserPowerLevels } , utils:: { self , room_name_or_id , unix_time_millis_to_datetime , ImageFormat , MEDIA_THUMBNAIL_FORMAT }
35+ sliding_sync:: { BackwardsPaginateUntilEventRequest , MatrixRequest , PaginationDirection , TimelineEndpoints , TimelineRequestSender , UserPowerLevels , get_client , submit_async_request , take_timeline_endpoints } , utils:: { self , ImageFormat , MEDIA_THUMBNAIL_FORMAT , room_name_or_id , unix_time_millis_to_datetime }
3836} ;
3937use crate :: home:: event_reaction_list:: ReactionListWidgetRefExt ;
4038use crate :: home:: room_read_receipt:: AvatarRowWidgetRefExt ;
@@ -1435,9 +1433,10 @@ impl RoomScreen {
14351433 action : & Action ,
14361434 pane : & UserProfileSlidingPaneRef ,
14371435 ) -> bool {
1436+ let uid = self . widget_uid ( ) ;
14381437 // A closure that handles both MatrixToUri and MatrixUri links,
14391438 // and returns whether the link was handled.
1440- let mut handle_matrix_link = |id : & MatrixId , _via : & [ OwnedServerName ] | -> bool {
1439+ let mut handle_matrix_link = |id : & MatrixId , via : & [ OwnedServerName ] | -> bool {
14411440 match id {
14421441 MatrixId :: User ( user_id) => {
14431442 // There is no synchronous way to get the user's full profile info
@@ -1474,20 +1473,86 @@ impl RoomScreen {
14741473 } ) ;
14751474 return true ;
14761475 }
1477- if let Some ( _known_room) = get_client ( ) . and_then ( |c| c. get_room ( room_id) ) {
1478- log ! ( "TODO: jump to known room {}" , room_id) ;
1476+ if let Some ( known_room) = get_client ( ) . and_then ( |c| c. get_room ( room_id) ) {
1477+ if known_room. is_space ( ) {
1478+ // TODO: Show space home page
1479+ enqueue_popup_notification ( PopupItem {
1480+ message : "Showing a space's home page is not yet supported." . into ( ) ,
1481+ kind : PopupKind :: Warning ,
1482+ auto_dismissal_duration : Some ( 3.0 )
1483+ } ) ;
1484+ }
1485+
1486+ if known_room. is_tombstoned ( ) {
1487+ // TODO: To join the successor room, we need to: known_room.tombstone_content()
1488+ enqueue_popup_notification ( PopupItem {
1489+ message : "This room has been replaced by another room. You must join the new room." . into ( ) ,
1490+ kind : PopupKind :: Warning ,
1491+ auto_dismissal_duration : None
1492+ } ) ;
1493+ }
1494+
1495+ match known_room. state ( ) {
1496+ RoomState :: Joined => {
1497+ cx. widget_action (
1498+ uid,
1499+ & Scope :: empty ( ) . path ,
1500+ RoomsListAction :: Selected (
1501+ SelectedRoom :: JoinedRoom {
1502+ room_id : known_room. room_id ( ) . to_owned ( ) . into ( ) ,
1503+ room_name : known_room. name ( ) ,
1504+ }
1505+ )
1506+ ) ;
1507+ }
1508+ RoomState :: Invited => {
1509+ cx. widget_action (
1510+ uid,
1511+ & Scope :: empty ( ) . path ,
1512+ RoomsListAction :: Selected (
1513+ SelectedRoom :: InvitedRoom {
1514+ room_id : known_room. room_id ( ) . to_owned ( ) . into ( ) ,
1515+ room_name : known_room. name ( ) ,
1516+ }
1517+ )
1518+ ) ;
1519+ }
1520+ RoomState :: Knocked => {
1521+ enqueue_popup_notification ( PopupItem {
1522+ message : "Already knocked. Waiting for approval." . into ( ) ,
1523+ kind : PopupKind :: Info ,
1524+ auto_dismissal_duration : None
1525+ } ) ;
1526+ }
1527+ RoomState :: Banned => {
1528+ enqueue_popup_notification ( PopupItem {
1529+ message : "You are banned from that room. You cannot join. Unless the admin lifts the ban." . into ( ) ,
1530+ kind : PopupKind :: Error ,
1531+ auto_dismissal_duration : None
1532+ } ) ;
1533+ }
1534+ RoomState :: Left => {
1535+ enqueue_popup_notification ( PopupItem {
1536+ message : "You have left that room. You must be re-invited to join again." . into ( ) ,
1537+ kind : PopupKind :: Info ,
1538+ auto_dismissal_duration : None
1539+ } ) ;
1540+ }
1541+ }
14791542 } else {
1480- log ! ( "TODO: fetch and display room preview for room {}" , room_id) ;
1543+ submit_async_request ( MatrixRequest :: GetRoomPreview {
1544+ room_or_alias_id : room_id. to_owned ( ) . into ( ) ,
1545+ via : via. to_owned ( ) ,
1546+ } ) ;
14811547 }
1482- false
1548+ true
14831549 }
14841550 MatrixId :: RoomAlias ( room_alias) => {
1485- log ! ( "TODO: open room alias {}" , room_alias) ;
1486- // TODO: open a room loading screen that shows a spinner
1487- // while our background async task calls Client::resolve_room_alias()
1488- // and then either jumps to the room if known, or fetches and displays
1489- // a room preview for that room.
1490- false
1551+ submit_async_request ( MatrixRequest :: GetRoomPreview {
1552+ room_or_alias_id : room_alias. to_owned ( ) . into ( ) ,
1553+ via : via. to_owned ( ) ,
1554+ } ) ;
1555+ true
14911556 }
14921557 MatrixId :: Event ( room_id, event_id) => {
14931558 log ! ( "TODO: open event {} in room {}" , event_id, room_id) ;
0 commit comments