Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
-----
* [*] Fix a layout issue impacting the "No media matching your search" empty state message of the Media Picker screen. [#19820]

21.5.1
-----
* [*] [Jetpack-only] Fixed a bug where the Login flow was restarting every time the app enters the foreground. [#19961]

21.5
-----
* [***] [internal] A significant refactor to the app’s architecture was made to allow for the new simplified UI. Regression testing on the app’s main flows is needed. [#19817]
Expand Down
6 changes: 6 additions & 0 deletions WordPress/Classes/System/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class WindowManager: NSObject {
///
private(set) var isShowingFullscreenSignIn = false

/// The root view controller for the window.
///
var rootViewController: UIViewController? {
return window.rootViewController
}

init(window: UIWindow) {
self.window = window
}
Expand Down
34 changes: 32 additions & 2 deletions WordPress/Jetpack/Classes/System/JetpackWindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,41 @@ private extension JetpackWindowManager {
!hasFailedExportAttempts,
let schemeUrl = URL(string: "\(AppScheme.wordpressMigrationV1.rawValue)\(WordPressExportRoute().path.removingPrefix("/"))")
else {
showSignInUI()
performSafeRootNavigation { [weak self] in
self?.showSignInUI()
}
return
}

/// WordPress is a compatible version for migrations, but needs to be loaded to prepare the data
showLoadWordPressUI(schemeUrl: schemeUrl)
performSafeRootNavigation { [weak self] in
self?.showLoadWordPressUI(schemeUrl: schemeUrl)
}
}

/// This method takes care of preventing screens being abruptly replaced.
///
/// Since the import method is called whenever the app is foregrounded, we want to make sure that
/// any root view controller replacements only happen where it is "allowed":
///
/// 1. When there's no root view controller yet, or
/// 2. When the Load WordPress screen is shown.
///
/// Note: We should remove this method when the migration phase is concluded and we no longer need
/// to perfom the migration.
///
/// - Parameter navigationClosure: The closure containing logic that eventually calls the `show` method.
func performSafeRootNavigation(with navigationClosure: @escaping () -> Void) {
switch rootViewController {
case .none:
// we can perform the navigation directly when there's no root view controller yet.
navigationClosure()
case .some(let viewController) where viewController is MigrationLoadWordPressViewController:
// allow the Load WordPress view to be replaced in case the migration process fails.
viewController.dismiss(animated: true, completion: navigationClosure)
default:
// do nothing when another root view controller is already displayed.
break
}
}
}