From 3e637be1ba768a28be32e10057df960cc808f74e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 27 Nov 2026 21:09:35 -0800 Subject: [PATCH] Avoid unneeded navbar and toolbar visibility changes in article view to avoid (hopefully) a UINavigationBar assertion during transitions. --- iOS/Article/WebViewController.swift | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index f147548be..aa6fa62ab 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -302,8 +302,7 @@ final class WebViewController: UIViewController { coordinator.showStatusBar() topShowBarsViewConstraint?.constant = 0 bottomShowBarsViewConstraint?.constant = 0 - navigationController?.setNavigationBarHidden(false, animated: animated) - navigationController?.setToolbarHidden(false, animated: animated) + setBarsHidden(false, animated: animated) additionalSafeAreaInsets.bottom = 0 setBottomScrollEdgeEffectHidden(false) configureContextMenuInteraction() @@ -315,13 +314,25 @@ final class WebViewController: UIViewController { coordinator.hideStatusBar() topShowBarsViewConstraint?.constant = -44.0 bottomShowBarsViewConstraint?.constant = 44.0 - navigationController?.setNavigationBarHidden(true, animated: true) - navigationController?.setToolbarHidden(true, animated: true) + setBarsHidden(true, animated: true) setBottomScrollEdgeEffectHidden(true) configureContextMenuInteraction() } } + /// Skips calls that wouldn’t change anything. + private func setBarsHidden(_ hidden: Bool, animated: Bool) { + guard let navigationController else { + return + } + if navigationController.isNavigationBarHidden != hidden { + navigationController.setNavigationBarHidden(hidden, animated: animated) + } + if navigationController.isToolbarHidden != hidden { + navigationController.setToolbarHidden(hidden, animated: animated) + } + } + func toggleArticleExtractor() { guard let article = article else {