mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Handle Room Routing using the membership state (#2154)
This commit is contained in:
@@ -252,15 +252,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle here the account switching when available
|
// Handle here the account switching when available
|
||||||
|
handleAppRoute(.room(roomID: roomID))
|
||||||
switch content.categoryIdentifier {
|
|
||||||
case NotificationConstants.Category.message:
|
|
||||||
handleAppRoute(.room(roomID: roomID))
|
|
||||||
case NotificationConstants.Category.invite:
|
|
||||||
handleAppRoute(.invites)
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleInlineReply(_ service: NotificationManagerProtocol, content: UNNotificationContent, replyText: String) async {
|
func handleInlineReply(_ service: NotificationManagerProtocol, content: UNNotificationContent, replyText: String) async {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ enum AppRoute: Equatable {
|
|||||||
case room(roomID: String)
|
case room(roomID: String)
|
||||||
case roomDetails(roomID: String)
|
case roomDetails(roomID: String)
|
||||||
case roomMemberDetails(userID: String)
|
case roomMemberDetails(userID: String)
|
||||||
case invites
|
|
||||||
case genericCallLink(url: URL)
|
case genericCallLink(url: URL)
|
||||||
case settings
|
case settings
|
||||||
case chatBackupSettings
|
case chatBackupSettings
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
MXLog.error("[RoomFlowCoordinator] Failed to get member: RoomProxy is nil")
|
MXLog.error("[RoomFlowCoordinator] Failed to get member: RoomProxy is nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .invites, .genericCallLink, .oidcCallback, .settings, .chatBackupSettings:
|
case .genericCallLink, .oidcCallback, .settings, .chatBackupSettings:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,13 +151,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
switch appRoute {
|
switch appRoute {
|
||||||
case .room, .roomDetails, .roomList, .roomMemberDetails:
|
case .room(let roomID):
|
||||||
self.roomFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
Task {
|
||||||
case .invites:
|
await self.handleRoomRoute(roomID: roomID, animated: animated)
|
||||||
if UIDevice.current.isPhone {
|
|
||||||
self.roomFlowCoordinator.clearRoute(animated: animated)
|
|
||||||
}
|
}
|
||||||
self.stateMachine.processEvent(.showInvitesScreen, userInfo: .init(animated: animated))
|
case .roomDetails, .roomList, .roomMemberDetails:
|
||||||
|
self.roomFlowCoordinator.handleAppRoute(appRoute, animated: animated)
|
||||||
case .genericCallLink(let url):
|
case .genericCallLink(let url):
|
||||||
self.navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated)
|
self.navigationSplitCoordinator.setSheetCoordinator(GenericCallLinkCoordinator(parameters: .init(url: url)), animated: animated)
|
||||||
case .oidcCallback:
|
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) {
|
func clearRoute(animated: Bool) {
|
||||||
fatalError("not necessary as of right now")
|
fatalError("not necessary as of right now")
|
||||||
|
|||||||
@@ -1878,6 +1878,11 @@ class RoomProxyMock: RoomProxyProtocol {
|
|||||||
set(value) { underlyingIsTombstoned = value }
|
set(value) { underlyingIsTombstoned = value }
|
||||||
}
|
}
|
||||||
var underlyingIsTombstoned: Bool!
|
var underlyingIsTombstoned: Bool!
|
||||||
|
var membership: Membership {
|
||||||
|
get { return underlyingMembership }
|
||||||
|
set(value) { underlyingMembership = value }
|
||||||
|
}
|
||||||
|
var underlyingMembership: Membership!
|
||||||
var hasOngoingCall: Bool {
|
var hasOngoingCall: Bool {
|
||||||
get { return underlyingHasOngoingCall }
|
get { return underlyingHasOngoingCall }
|
||||||
set(value) { underlyingHasOngoingCall = value }
|
set(value) { underlyingHasOngoingCall = value }
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ enum NotificationConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum Category {
|
enum Category {
|
||||||
static let discard = "discard"
|
|
||||||
static let message = "message"
|
static let message = "message"
|
||||||
static let invite = "invite"
|
static let invite = "invite"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ class RoomProxy: RoomProxyProtocol {
|
|||||||
room.membership() == .joined
|
room.membership() == .joined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var membership: Membership {
|
||||||
|
room.membership()
|
||||||
|
}
|
||||||
|
|
||||||
var isDirect: Bool {
|
var isDirect: Bool {
|
||||||
room.isDirect()
|
room.isDirect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ protocol RoomProxyProtocol {
|
|||||||
var isSpace: Bool { get }
|
var isSpace: Bool { get }
|
||||||
var isEncrypted: Bool { get }
|
var isEncrypted: Bool { get }
|
||||||
var isTombstoned: Bool { get }
|
var isTombstoned: Bool { get }
|
||||||
|
var membership: Membership { get }
|
||||||
var hasOngoingCall: Bool { get }
|
var hasOngoingCall: Bool { get }
|
||||||
var canonicalAlias: String? { get }
|
var canonicalAlias: String? { get }
|
||||||
var alternativeAliases: [String] { get }
|
var alternativeAliases: [String] { get }
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
If an invite notification has already been accepted tapping on it will bring you to the invite screen.
|
||||||
Reference in New Issue
Block a user