mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Disable animations when tapping on a notifications while the app is backgrounded (#808)
* tapping on notifications will display the animation only if the app is active and foregrounded * changelog
This commit is contained in:
@@ -267,7 +267,7 @@ class AppCoordinator: AppCoordinatorProtocol {
|
|||||||
navigationRootCoordinator.setRootCoordinator(navigationSplitCoordinator)
|
navigationRootCoordinator.setRootCoordinator(navigationSplitCoordinator)
|
||||||
|
|
||||||
if let storedAppRoute {
|
if let storedAppRoute {
|
||||||
userSessionFlowCoordinator.handleAppRoute(storedAppRoute)
|
userSessionFlowCoordinator.handleAppRoute(storedAppRoute, animated: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +441,7 @@ class AppCoordinator: AppCoordinatorProtocol {
|
|||||||
|
|
||||||
private func handleAppRoute(_ appRoute: AppRoute) {
|
private func handleAppRoute(_ appRoute: AppRoute) {
|
||||||
if let userSessionFlowCoordinator {
|
if let userSessionFlowCoordinator {
|
||||||
userSessionFlowCoordinator.handleAppRoute(appRoute)
|
userSessionFlowCoordinator.handleAppRoute(appRoute, animated: UIApplication.shared.applicationState == .active)
|
||||||
} else {
|
} else {
|
||||||
storedAppRoute = appRoute
|
storedAppRoute = appRoute
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,16 +64,16 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
stateMachine.isDisplayingRoomScreen(withRoomId: roomId)
|
stateMachine.isDisplayingRoomScreen(withRoomId: roomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleAppRoute(_ appRoute: AppRoute) {
|
func handleAppRoute(_ appRoute: AppRoute, animated: Bool) {
|
||||||
switch stateMachine.state {
|
switch stateMachine.state {
|
||||||
case .feedbackScreen, .sessionVerificationScreen, .settingsScreen, .startChatScreen, .invitesScreen:
|
case .feedbackScreen, .sessionVerificationScreen, .settingsScreen, .startChatScreen, .invitesScreen:
|
||||||
navigationSplitCoordinator.setSheetCoordinator(nil)
|
navigationSplitCoordinator.setSheetCoordinator(nil, animated: animated)
|
||||||
case .roomList, .initial:
|
case .roomList, .initial:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch appRoute {
|
switch appRoute {
|
||||||
case .room(let roomID):
|
case .room(let roomID):
|
||||||
stateMachine.processEvent(.selectRoom(roomId: roomID))
|
stateMachine.processEvent(.selectRoom(roomId: roomID), userInfo: .init(animated: animated))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
private func setupStateMachine() {
|
private func setupStateMachine() {
|
||||||
stateMachine.addTransitionHandler { [weak self] context in
|
stateMachine.addTransitionHandler { [weak self] context in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
let animated = (context.userInfo as? EventUserInfo)?.animated ?? true
|
||||||
switch (context.fromState, context.event, context.toState) {
|
switch (context.fromState, context.event, context.toState) {
|
||||||
case (.initial, .start, .roomList):
|
case (.initial, .start, .roomList):
|
||||||
self.presentHomeScreen()
|
self.presentHomeScreen()
|
||||||
@@ -94,31 +94,31 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.presentRoomWithIdentifier(selectedRoomId)
|
self.presentRoomWithIdentifier(selectedRoomId, animated: animated)
|
||||||
case(.roomList, .deselectRoom, .roomList):
|
case(.roomList, .deselectRoom, .roomList):
|
||||||
break
|
break
|
||||||
|
|
||||||
case (.roomList, .showSessionVerificationScreen, .sessionVerificationScreen):
|
case (.roomList, .showSessionVerificationScreen, .sessionVerificationScreen):
|
||||||
self.presentSessionVerification()
|
self.presentSessionVerification(animated: animated)
|
||||||
case (.sessionVerificationScreen, .dismissedSessionVerificationScreen, .roomList):
|
case (.sessionVerificationScreen, .dismissedSessionVerificationScreen, .roomList):
|
||||||
break
|
break
|
||||||
|
|
||||||
case (.roomList, .showSettingsScreen, .settingsScreen):
|
case (.roomList, .showSettingsScreen, .settingsScreen):
|
||||||
self.presentSettingsScreen()
|
self.presentSettingsScreen(animated: animated)
|
||||||
case (.settingsScreen, .dismissedSettingsScreen, .roomList):
|
case (.settingsScreen, .dismissedSettingsScreen, .roomList):
|
||||||
break
|
break
|
||||||
|
|
||||||
case (.roomList, .feedbackScreen, .feedbackScreen):
|
case (.roomList, .feedbackScreen, .feedbackScreen):
|
||||||
self.presentFeedbackScreen()
|
self.presentFeedbackScreen(animated: animated)
|
||||||
case (.feedbackScreen, .dismissedFeedbackScreen, .roomList):
|
case (.feedbackScreen, .dismissedFeedbackScreen, .roomList):
|
||||||
break
|
break
|
||||||
|
|
||||||
case (.roomList, .showStartChatScreen, .startChatScreen):
|
case (.roomList, .showStartChatScreen, .startChatScreen):
|
||||||
self.presentStartChat()
|
self.presentStartChat(animated: animated)
|
||||||
case (.startChatScreen, .dismissedStartChatScreen, .roomList):
|
case (.startChatScreen, .dismissedStartChatScreen, .roomList):
|
||||||
break
|
break
|
||||||
case (.roomList, .showInvitesScreen, .invitesScreen):
|
case (.roomList, .showInvitesScreen, .invitesScreen):
|
||||||
self.presentInvitesList()
|
self.presentInvitesList(animated: animated)
|
||||||
case (.invitesScreen, .closedInvitesScreen, .roomList):
|
case (.invitesScreen, .closedInvitesScreen, .roomList):
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@@ -166,7 +166,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
// MARK: Rooms
|
// MARK: Rooms
|
||||||
|
|
||||||
private func presentRoomWithIdentifier(_ roomIdentifier: String) {
|
private func presentRoomWithIdentifier(_ roomIdentifier: String, animated: Bool = true) {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else {
|
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else {
|
||||||
MXLog.error("Invalid room identifier: \(roomIdentifier)")
|
MXLog.error("Invalid room identifier: \(roomIdentifier)")
|
||||||
@@ -197,7 +197,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
detailNavigationStackCoordinator.setRootCoordinator(coordinator) { [weak self, roomIdentifier] in
|
detailNavigationStackCoordinator.setRootCoordinator(coordinator, animated: animated) { [weak self, roomIdentifier] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
// Move the state machine to no room selected if the room currently being dimissed
|
// Move the state machine to no room selected if the room currently being dimissed
|
||||||
@@ -210,7 +210,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if navigationSplitCoordinator.detailCoordinator == nil {
|
if navigationSplitCoordinator.detailCoordinator == nil {
|
||||||
navigationSplitCoordinator.setDetailCoordinator(detailNavigationStackCoordinator)
|
navigationSplitCoordinator.setDetailCoordinator(detailNavigationStackCoordinator, animated: animated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
// MARK: Settings
|
// MARK: Settings
|
||||||
|
|
||||||
private func presentSettingsScreen() {
|
private func presentSettingsScreen(animated: Bool) {
|
||||||
let settingsNavigationStackCoordinator = NavigationStackCoordinator()
|
let settingsNavigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let userIndicatorController = UserIndicatorController(rootCoordinator: settingsNavigationStackCoordinator)
|
let userIndicatorController = UserIndicatorController(rootCoordinator: settingsNavigationStackCoordinator)
|
||||||
@@ -243,7 +243,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsNavigationStackCoordinator.setRootCoordinator(settingsScreenCoordinator)
|
settingsNavigationStackCoordinator.setRootCoordinator(settingsScreenCoordinator, animated: animated)
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedSettingsScreen)
|
self?.stateMachine.processEvent(.dismissedSettingsScreen)
|
||||||
@@ -252,7 +252,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
// MARK: Session verification
|
// MARK: Session verification
|
||||||
|
|
||||||
private func presentSessionVerification() {
|
private func presentSessionVerification(animated: Bool) {
|
||||||
guard let sessionVerificationController = userSession.sessionVerificationController else {
|
guard let sessionVerificationController = userSession.sessionVerificationController else {
|
||||||
fatalError("The sessionVerificationController should aways be valid at this point")
|
fatalError("The sessionVerificationController should aways be valid at this point")
|
||||||
}
|
}
|
||||||
@@ -265,14 +265,14 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
self?.navigationSplitCoordinator.setSheetCoordinator(nil)
|
self?.navigationSplitCoordinator.setSheetCoordinator(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(coordinator) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(coordinator, animated: animated) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedSessionVerificationScreen)
|
self?.stateMachine.processEvent(.dismissedSessionVerificationScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Start Chat
|
// MARK: Start Chat
|
||||||
|
|
||||||
private func presentStartChat() {
|
private func presentStartChat(animated: Bool) {
|
||||||
let startChatNavigationStackCoordinator = NavigationStackCoordinator()
|
let startChatNavigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let userIndicatorController = UserIndicatorController(rootCoordinator: startChatNavigationStackCoordinator)
|
let userIndicatorController = UserIndicatorController(rootCoordinator: startChatNavigationStackCoordinator)
|
||||||
@@ -293,14 +293,14 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
startChatNavigationStackCoordinator.setRootCoordinator(coordinator)
|
startChatNavigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController, animated: animated) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedStartChatScreen)
|
self?.stateMachine.processEvent(.dismissedStartChatScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Bug reporting
|
// MARK: Bug reporting
|
||||||
|
|
||||||
private func presentFeedbackScreen(for image: UIImage? = nil) {
|
private func presentFeedbackScreen(animated: Bool, for image: UIImage? = nil) {
|
||||||
let feedbackNavigationStackCoordinator = NavigationStackCoordinator()
|
let feedbackNavigationStackCoordinator = NavigationStackCoordinator()
|
||||||
|
|
||||||
let userIndicatorController = UserIndicatorController(rootCoordinator: feedbackNavigationStackCoordinator)
|
let userIndicatorController = UserIndicatorController(rootCoordinator: feedbackNavigationStackCoordinator)
|
||||||
@@ -318,14 +318,14 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
|
|
||||||
feedbackNavigationStackCoordinator.setRootCoordinator(coordinator)
|
feedbackNavigationStackCoordinator.setRootCoordinator(coordinator)
|
||||||
|
|
||||||
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController) { [weak self] in
|
navigationSplitCoordinator.setSheetCoordinator(userIndicatorController, animated: animated) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.dismissedFeedbackScreen)
|
self?.stateMachine.processEvent(.dismissedFeedbackScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Invites list
|
// MARK: Invites list
|
||||||
|
|
||||||
private func presentInvitesList() {
|
private func presentInvitesList(animated: Bool) {
|
||||||
let parameters = InvitesCoordinatorParameters(userSession: userSession)
|
let parameters = InvitesCoordinatorParameters(userSession: userSession)
|
||||||
let coordinator = InvitesCoordinator(parameters: parameters)
|
let coordinator = InvitesCoordinator(parameters: parameters)
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ class UserSessionFlowCoordinator: CoordinatorProtocol {
|
|||||||
.sink { _ in }
|
.sink { _ in }
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
navigationSplitCoordinator.setDetailCoordinator(coordinator) { [weak self] in
|
navigationSplitCoordinator.setDetailCoordinator(coordinator, animated: animated) { [weak self] in
|
||||||
self?.stateMachine.processEvent(.closedInvitesScreen)
|
self?.stateMachine.processEvent(.closedInvitesScreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ class UserSessionFlowCoordinatorStateMachine {
|
|||||||
|
|
||||||
/// Attempt to move the state machine to another state through an event
|
/// Attempt to move the state machine to another state through an event
|
||||||
/// It will either invoke the `transitionHandler` or the `errorHandler` depending on its current state
|
/// It will either invoke the `transitionHandler` or the `errorHandler` depending on its current state
|
||||||
func processEvent(_ event: Event) {
|
func processEvent(_ event: Event, userInfo: EventUserInfo? = nil) {
|
||||||
stateMachine.tryEvent(event)
|
stateMachine.tryEvent(event, userInfo: userInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers a callback for processing state machine transitions
|
/// Registers a callback for processing state machine transitions
|
||||||
@@ -166,3 +166,7 @@ class UserSessionFlowCoordinatorStateMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct EventUserInfo {
|
||||||
|
let animated: Bool
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Animations are disabled when tapping on an animations when the app is in background.
|
||||||
Reference in New Issue
Block a user