mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Handle Room Routing using the membership state (#2154)
This commit is contained in:
parent
0dbceceac3
commit
a21bc2cdd3
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
@ -168,6 +167,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")
|
||||
}
|
||||
|
@ -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 }
|
||||
|
@ -27,7 +27,6 @@ enum NotificationConstants {
|
||||
}
|
||||
|
||||
enum Category {
|
||||
static let discard = "discard"
|
||||
static let message = "message"
|
||||
static let invite = "invite"
|
||||
}
|
||||
|
@ -131,6 +131,10 @@ class RoomProxy: RoomProxyProtocol {
|
||||
room.membership() == .joined
|
||||
}
|
||||
|
||||
var membership: Membership {
|
||||
room.membership()
|
||||
}
|
||||
|
||||
var isDirect: Bool {
|
||||
room.isDirect()
|
||||
}
|
||||
|
@ -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
1
changelog.d/2150.bugfix
Normal file
@ -0,0 +1 @@
|
||||
If an invite notification has already been accepted tapping on it will bring you to the invite screen.
|
Loading…
x
Reference in New Issue
Block a user