From 175a8a8aea8a268bb08f81d124a4a0b84e4002dd Mon Sep 17 00:00:00 2001 From: yostyle Date: Tue, 12 Apr 2022 19:16:58 +0200 Subject: [PATCH 1/2] Show room after accepting invite --- Riot/Modules/Common/Recents/RecentsViewController.m | 8 ++++++-- changelog.d/4986.change | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog.d/4986.change diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 6dbd905f94..f8b5eea15c 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -1018,9 +1018,13 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac return; } - // Accept invitation + // Accept invitation and show room Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerInvite; - [self joinRoom:invitedRoom completion:nil]; + [self joinRoom:invitedRoom completion:^(BOOL succeed) { + if (succeed) { + [self showRoomWithRoomId:invitedRoom.roomId inMatrixSession:invitedRoom.mxSession]; + } + }]; } else if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellDeclineButtonPressed]) { diff --git a/changelog.d/4986.change b/changelog.d/4986.change new file mode 100644 index 0000000000..758e0b5368 --- /dev/null +++ b/changelog.d/4986.change @@ -0,0 +1 @@ +Open the room when user accepts an invite from the room list From d01c1a3e506520420e36f911411423899da26a28 Mon Sep 17 00:00:00 2001 From: yostyle Date: Wed, 13 Apr 2022 18:27:17 +0200 Subject: [PATCH 2/2] Use autojoin boolean --- .../RoomNavigationParameters.swift | 19 ++++++++++++++++++- .../Common/Recents/RecentsViewController.m | 16 +++++++++------- Riot/Modules/Room/RoomCoordinator.swift | 1 + .../Room/RoomCoordinatorParameters.swift | 16 ++++++++++++---- Riot/Modules/Room/RoomViewController.m | 6 ++---- Riot/Modules/TabBar/TabBarCoordinator.swift | 4 +++- 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/Riot/Modules/Application/ScreenNavigation/RoomNavigationParameters.swift b/Riot/Modules/Application/ScreenNavigation/RoomNavigationParameters.swift index 184b413e07..3f799d82b6 100644 --- a/Riot/Modules/Application/ScreenNavigation/RoomNavigationParameters.swift +++ b/Riot/Modules/Application/ScreenNavigation/RoomNavigationParameters.swift @@ -61,13 +61,18 @@ class RoomNavigationParameters: NSObject { /// ID of the sender of the notification. Default `nil` let senderId: String? + /// If `true`, the invited room is automatically joined. + let autoJoinInvitedRoom: Bool + // MARK: - Setup init(roomId: String, eventId: String?, mxSession: MXSession, threadParameters: ThreadParameters?, - presentationParameters: ScreenPresentationParameters) { + presentationParameters: ScreenPresentationParameters, + autoJoinInvitedRoom: Bool + ) { self.roomId = roomId self.eventId = eventId self.mxSession = mxSession @@ -75,10 +80,20 @@ class RoomNavigationParameters: NSObject { self.presentationParameters = presentationParameters self.showSettingsInitially = false self.senderId = nil + self.autoJoinInvitedRoom = autoJoinInvitedRoom super.init() } + convenience init(roomId: String, + eventId: String?, + mxSession: MXSession, + threadParameters: ThreadParameters?, + presentationParameters: ScreenPresentationParameters + ) { + self.init(roomId: roomId, eventId: eventId, mxSession: mxSession, threadParameters: threadParameters, presentationParameters: presentationParameters, autoJoinInvitedRoom: false) + } + init(roomId: String, eventId: String?, mxSession: MXSession, @@ -92,6 +107,7 @@ class RoomNavigationParameters: NSObject { self.presentationParameters = presentationParameters self.showSettingsInitially = false self.senderId = senderId + self.autoJoinInvitedRoom = false super.init() } @@ -108,6 +124,7 @@ class RoomNavigationParameters: NSObject { self.showSettingsInitially = showSettingsInitially self.threadParameters = nil self.senderId = nil + self.autoJoinInvitedRoom = false super.init() } diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index f8b5eea15c..7bcd3abbbc 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -895,6 +895,11 @@ - (void)showPublicRoomsDirectory } - (void)showRoomWithRoomId:(NSString*)roomId inMatrixSession:(MXSession*)matrixSession +{ + [self showRoomWithRoomId:roomId andAutoJoinInvitedRoom:false inMatrixSession:matrixSession]; +} + +- (void)showRoomWithRoomId:(NSString*)roomId andAutoJoinInvitedRoom:(BOOL)autoJoinInvitedRoom inMatrixSession:(MXSession*)matrixSession { MXRoom *room = [matrixSession roomWithRoomId:roomId]; if (room.summary.membership == MXMembershipInvite) @@ -912,7 +917,8 @@ - (void)showRoomWithRoomId:(NSString*)roomId inMatrixSession:(MXSession*)matrixS eventId:nil mxSession:matrixSession threadParameters:nil - presentationParameters:presentationParameters]; + presentationParameters:presentationParameters + autoJoinInvitedRoom:autoJoinInvitedRoom]; [[AppDelegate theDelegate] showRoomWithParameters:parameters completion:^{ self.userInteractionEnabled = YES; @@ -1018,13 +1024,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac return; } - // Accept invitation and show room + // Accept invitation and display the room Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerInvite; - [self joinRoom:invitedRoom completion:^(BOOL succeed) { - if (succeed) { - [self showRoomWithRoomId:invitedRoom.roomId inMatrixSession:invitedRoom.mxSession]; - } - }]; + [self showRoomWithRoomId:invitedRoom.roomId andAutoJoinInvitedRoom:true inMatrixSession:invitedRoom.mxSession]; } else if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellDeclineButtonPressed]) { diff --git a/Riot/Modules/Room/RoomCoordinator.swift b/Riot/Modules/Room/RoomCoordinator.swift index 15aebef411..bdb355b238 100644 --- a/Riot/Modules/Room/RoomCoordinator.swift +++ b/Riot/Modules/Room/RoomCoordinator.swift @@ -170,6 +170,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol { self.stopLoading() if let roomDataSource = roomDataSource { + self.roomViewController.autoJoinInvitedRoom = self.parameters.autoJoinInvitedRoom self.roomViewController.displayRoom(roomDataSource) } diff --git a/Riot/Modules/Room/RoomCoordinatorParameters.swift b/Riot/Modules/Room/RoomCoordinatorParameters.swift index ebe36d8376..faae3dd8b8 100644 --- a/Riot/Modules/Room/RoomCoordinatorParameters.swift +++ b/Riot/Modules/Room/RoomCoordinatorParameters.swift @@ -55,6 +55,9 @@ struct RoomCoordinatorParameters { /// If `true`, the room settings screen will be initially displayed. Default `false` let showSettingsInitially: Bool + /// If `true`, the invited room is automatically joined. + let autoJoinInvitedRoom: Bool + // MARK: - Setup private init(navigationRouter: NavigationRouterType?, @@ -67,7 +70,8 @@ struct RoomCoordinatorParameters { threadId: String?, displayConfiguration: RoomDisplayConfiguration, previewData: RoomPreviewData?, - showSettingsInitially: Bool) { + showSettingsInitially: Bool, + autoJoinInvitedRoom: Bool) { self.navigationRouter = navigationRouter self.navigationRouterStore = navigationRouterStore self.userIndicatorPresenter = userIndicatorPresenter @@ -79,6 +83,7 @@ struct RoomCoordinatorParameters { self.displayConfiguration = displayConfiguration self.previewData = previewData self.showSettingsInitially = showSettingsInitially + self.autoJoinInvitedRoom = autoJoinInvitedRoom } /// Init to present a joined room @@ -91,7 +96,8 @@ struct RoomCoordinatorParameters { eventId: String? = nil, threadId: String? = nil, showSettingsInitially: Bool, - displayConfiguration: RoomDisplayConfiguration = .default) { + displayConfiguration: RoomDisplayConfiguration = .default, + autoJoinInvitedRoom: Bool = false) { self.init(navigationRouter: navigationRouter, navigationRouterStore: navigationRouterStore, @@ -103,7 +109,8 @@ struct RoomCoordinatorParameters { threadId: threadId, displayConfiguration: displayConfiguration, previewData: nil, - showSettingsInitially: showSettingsInitially) + showSettingsInitially: showSettingsInitially, + autoJoinInvitedRoom: autoJoinInvitedRoom) } /// Init to present a room preview @@ -123,6 +130,7 @@ struct RoomCoordinatorParameters { threadId: nil, displayConfiguration: .default, previewData: previewData, - showSettingsInitially: false) + showSettingsInitially: false, + autoJoinInvitedRoom: false) } } diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 8f612b0b78..c926db5fe4 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1066,10 +1066,8 @@ - (void)onRoomDataSourceReady // Show preview header [self showPreviewHeader:YES]; } - else - { - [super onRoomDataSourceReady]; - } + + [super onRoomDataSourceReady]; } - (void)updateViewControllerAppearanceOnRoomDataSourceState diff --git a/Riot/Modules/TabBar/TabBarCoordinator.swift b/Riot/Modules/TabBar/TabBarCoordinator.swift index d560e73c65..a35e0429fa 100644 --- a/Riot/Modules/TabBar/TabBarCoordinator.swift +++ b/Riot/Modules/TabBar/TabBarCoordinator.swift @@ -428,7 +428,9 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType { roomId: roomNavigationParameters.roomId, eventId: roomNavigationParameters.eventId, threadId: threadId, - showSettingsInitially: roomNavigationParameters.showSettingsInitially, displayConfiguration: displayConfig) + showSettingsInitially: roomNavigationParameters.showSettingsInitially, + displayConfiguration: displayConfig, + autoJoinInvitedRoom: roomNavigationParameters.autoJoinInvitedRoom) self.showRoom(with: roomCoordinatorParameters, stackOnSplitViewDetail: roomNavigationParameters.presentationParameters.stackAboveVisibleViews,