diff --git a/ElementX/Sources/Application/AppCoordinator.swift b/ElementX/Sources/Application/AppCoordinator.swift index af407ca99..ff21cbc30 100644 --- a/ElementX/Sources/Application/AppCoordinator.swift +++ b/ElementX/Sources/Application/AppCoordinator.swift @@ -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 { diff --git a/ElementX/Sources/Application/Navigation/AppRoutes.swift b/ElementX/Sources/Application/Navigation/AppRoutes.swift index 8b1573fca..ec0e6daa7 100644 --- a/ElementX/Sources/Application/Navigation/AppRoutes.swift +++ b/ElementX/Sources/Application/Navigation/AppRoutes.swift @@ -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 diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 7d5ced788..c95071b02 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -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 } } diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 2e182a519..cda06257d 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -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") diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index f8030dda0..5f334b4e1 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -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 } diff --git a/ElementX/Sources/Services/Notification/NotificationConstants.swift b/ElementX/Sources/Services/Notification/NotificationConstants.swift index 0694b8f58..579d6cbe1 100644 --- a/ElementX/Sources/Services/Notification/NotificationConstants.swift +++ b/ElementX/Sources/Services/Notification/NotificationConstants.swift @@ -27,7 +27,6 @@ enum NotificationConstants { } enum Category { - static let discard = "discard" static let message = "message" static let invite = "invite" } diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index 65a26ef24..156b80c70 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -131,6 +131,10 @@ class RoomProxy: RoomProxyProtocol { room.membership() == .joined } + var membership: Membership { + room.membership() + } + var isDirect: Bool { room.isDirect() } diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index 6cf9699a2..d6b53fcd3 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -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 } diff --git a/changelog.d/2150.bugfix b/changelog.d/2150.bugfix new file mode 100644 index 000000000..3a54f8b9f --- /dev/null +++ b/changelog.d/2150.bugfix @@ -0,0 +1 @@ +If an invite notification has already been accepted tapping on it will bring you to the invite screen. \ No newline at end of file