Handle Room Routing using the membership state (#2154)

This commit is contained in:
Mauro 2023-11-22 18:37:26 +01:00 committed by GitHub
parent 0dbceceac3
commit a21bc2cdd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 18 deletions

View File

@ -252,15 +252,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
}
// Handle here the account switching when available
switch content.categoryIdentifier {
case NotificationConstants.Category.message:
handleAppRoute(.room(roomID: roomID))
case NotificationConstants.Category.invite:
handleAppRoute(.invites)
default:
break
}
handleAppRoute(.room(roomID: roomID))
}
func handleInlineReply(_ service: NotificationManagerProtocol, content: UNNotificationContent, replyText: String) async {

View File

@ -22,7 +22,6 @@ enum AppRoute: Equatable {
case room(roomID: String)
case roomDetails(roomID: String)
case roomMemberDetails(userID: String)
case invites
case genericCallLink(url: URL)
case settings
case chatBackupSettings

View File

@ -106,7 +106,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
MXLog.error("[RoomFlowCoordinator] Failed to get member: RoomProxy is nil")
}
}
case .invites, .genericCallLink, .oidcCallback, .settings, .chatBackupSettings:
case .genericCallLink, .oidcCallback, .settings, .chatBackupSettings:
break
}
}

View File

@ -151,13 +151,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
guard let self else { return }
switch appRoute {
case .room, .roomDetails, .roomList, .roomMemberDetails:
self.roomFlowCoordinator.handleAppRoute(appRoute, animated: animated)
case .invites:
if UIDevice.current.isPhone {
self.roomFlowCoordinator.clearRoute(animated: animated)
case .room(let roomID):
Task {
await self.handleRoomRoute(roomID: roomID, animated: animated)
}
self.stateMachine.processEvent(.showInvitesScreen, userInfo: .init(animated: animated))
case .roomDetails, .roomList, .roomMemberDetails:
self.roomFlowCoordinator.handleAppRoute(appRoute, animated: animated)
case .genericCallLink(let url):
self.navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated)
case .oidcCallback:
@ -167,6 +166,21 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
}
}
private func handleRoomRoute(roomID: String, animated: Bool) async {
switch await userSession.clientProxy.roomForIdentifier(roomID)?.membership {
case .invited:
if UIDevice.current.isPhone {
roomFlowCoordinator.clearRoute(animated: animated)
}
stateMachine.processEvent(.showInvitesScreen, userInfo: .init(animated: animated))
case .joined:
roomFlowCoordinator.handleAppRoute(.room(roomID: roomID), animated: animated)
case .left, .none:
// Do nothing but maybe we should ask design to have some kind of error state
break
}
}
func clearRoute(animated: Bool) {
fatalError("not necessary as of right now")

View File

@ -1878,6 +1878,11 @@ class RoomProxyMock: RoomProxyProtocol {
set(value) { underlyingIsTombstoned = value }
}
var underlyingIsTombstoned: Bool!
var membership: Membership {
get { return underlyingMembership }
set(value) { underlyingMembership = value }
}
var underlyingMembership: Membership!
var hasOngoingCall: Bool {
get { return underlyingHasOngoingCall }
set(value) { underlyingHasOngoingCall = value }

View File

@ -27,7 +27,6 @@ enum NotificationConstants {
}
enum Category {
static let discard = "discard"
static let message = "message"
static let invite = "invite"
}

View File

@ -131,6 +131,10 @@ class RoomProxy: RoomProxyProtocol {
room.membership() == .joined
}
var membership: Membership {
room.membership()
}
var isDirect: Bool {
room.isDirect()
}

View File

@ -55,6 +55,7 @@ protocol RoomProxyProtocol {
var isSpace: Bool { get }
var isEncrypted: Bool { get }
var isTombstoned: Bool { get }
var membership: Membership { get }
var hasOngoingCall: Bool { get }
var canonicalAlias: String? { get }
var alternativeAliases: [String] { get }

1
changelog.d/2150.bugfix Normal file
View File

@ -0,0 +1 @@
If an invite notification has already been accepted tapping on it will bring you to the invite screen.