Merge pull request #3339 from stuartbreckenridge/3335

Fixes #3335
This commit is contained in:
Maurice Parker 2021-11-07 20:39:58 -06:00 committed by GitHub
commit 19055afeb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 0 deletions

View File

@ -210,6 +210,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
default:
if let sceneDelegate = response.targetScene?.delegate as? SceneDelegate {
sceneDelegate.handle(response)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
sceneDelegate.coordinator.dismissIfLaunchingFromExternalAction()
})
}
}

View File

@ -687,6 +687,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
present(vc, animated: true)
}
}
}
// MARK: UIContextMenuInteractionDelegate

View File

@ -1327,6 +1327,23 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
/// This will dismiss the foremost view controller if the user
/// has launched from an external action (i.e., a widget tap, or
/// selecting an artice via a notification).
///
/// The dismiss is only applicable if the view controller is a
/// `SFSafariViewController` or `SettingsViewController`,
/// otherwise, this function does nothing.
func dismissIfLaunchingFromExternalAction() {
guard let presentedController = masterFeedViewController.presentedViewController else { return }
if presentedController.isKind(of: SFSafariViewController.self) {
presentedController.dismiss(animated: true, completion: nil)
}
guard let settings = presentedController.children.first as? SettingsViewController else { return }
settings.dismiss(animated: true, completion: nil)
}
}
// MARK: UISplitViewControllerDelegate

View File

@ -105,6 +105,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let context = urlContexts.first else { return }
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.coordinator.dismissIfLaunchingFromExternalAction()
}
let urlString = context.url.absoluteString
// Handle the feed: and feeds: schemes
@ -202,6 +207,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
return
}
}
}
}