Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable memoization of reader screens on iPhone #23974

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
21 changes: 6 additions & 15 deletions WordPress/Classes/System/Root View/ReaderPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {

/// The navigation controller for the main content when shown using tabs.
private var mainNavigationController = UINavigationController()
private var latestContentVC: UIViewController?

private var viewContext: NSManagedObjectContext {
ContextManager.shared.mainContext
Expand Down Expand Up @@ -58,8 +57,8 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
// -warning: List occasionally sets the selection to `nil` when switching items.
selectionObserver = sidebarViewModel.$selection.compactMap { $0 }
.removeDuplicates { [weak self] in
guard $0 == $1 else { return false }
self?.popMainNavigationController()
guard $0 == $1, let self, let splitViewController else { return false }
self.popMainNavigationController(in: splitViewController)
return true
}
.sink { [weak self] in self?.configure(for: $0) }
Expand All @@ -84,17 +83,10 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
hideSupplementaryColumnIfNeeded()
}

private func popMainNavigationController() {
if let splitViewController {
let secondaryVC = splitViewController.viewController(for: .secondary)
(secondaryVC as? UINavigationController)?.popToRootViewController(animated: true)
hideSupplementaryColumnIfNeeded()
} else {
if let latestContentVC {
// Return to the previous view controller preserving its state
mainNavigationController.safePushViewController(latestContentVC, animated: true)
}
}
private func popMainNavigationController(in splitViewController: UISplitViewController) {
let secondaryVC = splitViewController.viewController(for: .secondary)
(secondaryVC as? UINavigationController)?.popToRootViewController(animated: true)
hideSupplementaryColumnIfNeeded()
}

private func hideSupplementaryColumnIfNeeded() {
Expand Down Expand Up @@ -190,7 +182,6 @@ final class ReaderPresenter: NSObject, SplitViewDisplayable {
}
splitViewController.setViewController(navigationVC, for: .secondary)
} else {
latestContentVC = viewController
mainNavigationController.safePushViewController(viewController, animated: true)
}
}
Expand Down
Loading