Skip to content
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

When accepting an invite, expecting to see the room #6035

Merged
merged 2 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,39 @@ 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
self.threadParameters = threadParameters
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,
Expand All @@ -92,6 +107,7 @@ class RoomNavigationParameters: NSObject {
self.presentationParameters = presentationParameters
self.showSettingsInitially = false
self.senderId = senderId
self.autoJoinInvitedRoom = false

super.init()
}
Expand All @@ -108,6 +124,7 @@ class RoomNavigationParameters: NSObject {
self.showSettingsInitially = showSettingsInitially
self.threadParameters = nil
self.senderId = nil
self.autoJoinInvitedRoom = false

super.init()
}
Expand Down
12 changes: 9 additions & 3 deletions Riot/Modules/Common/Recents/RecentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -1018,9 +1024,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac
return;
}

// Accept invitation
// Accept invitation and display the room
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerInvite;
[self joinRoom:invitedRoom completion:nil];
[self showRoomWithRoomId:invitedRoom.roomId andAutoJoinInvitedRoom:true inMatrixSession:invitedRoom.mxSession];
}
else if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellDeclineButtonPressed])
{
Expand Down
1 change: 1 addition & 0 deletions Riot/Modules/Room/RoomCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
16 changes: 12 additions & 4 deletions Riot/Modules/Room/RoomCoordinatorParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -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
Expand All @@ -79,6 +83,7 @@ struct RoomCoordinatorParameters {
self.displayConfiguration = displayConfiguration
self.previewData = previewData
self.showSettingsInitially = showSettingsInitially
self.autoJoinInvitedRoom = autoJoinInvitedRoom
}

/// Init to present a joined room
Expand All @@ -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,
Expand All @@ -103,7 +109,8 @@ struct RoomCoordinatorParameters {
threadId: threadId,
displayConfiguration: displayConfiguration,
previewData: nil,
showSettingsInitially: showSettingsInitially)
showSettingsInitially: showSettingsInitially,
autoJoinInvitedRoom: autoJoinInvitedRoom)
}

/// Init to present a room preview
Expand All @@ -123,6 +130,7 @@ struct RoomCoordinatorParameters {
threadId: nil,
displayConfiguration: .default,
previewData: previewData,
showSettingsInitially: false)
showSettingsInitially: false,
autoJoinInvitedRoom: false)
}
}
6 changes: 2 additions & 4 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,8 @@ - (void)onRoomDataSourceReady
// Show preview header
[self showPreviewHeader:YES];
}
else
{
[super onRoomDataSourceReady];
}

[super onRoomDataSourceReady];
}

- (void)updateViewControllerAppearanceOnRoomDataSourceState
Expand Down
4 changes: 3 additions & 1 deletion Riot/Modules/TabBar/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4986.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Open the room when user accepts an invite from the room list