Skip to content

Commit

Permalink
Use autojoin boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Apr 13, 2022
1 parent 175a8a8 commit 7adfb18
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 13 deletions.
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
16 changes: 9 additions & 7 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,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])
{
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)
}
}
5 changes: 5 additions & 0 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,11 @@ - (void)onRoomDataSourceReady

// Show preview header
[self showPreviewHeader:YES];

if (self.autoJoinInvitedRoom)
{
[self joinRoom:nil];
}
}
else
{
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

0 comments on commit 7adfb18

Please sign in to comment.