Fixes #3335
When the app is brought to the foreground from an external action (e.g., tapping on the widget, opening from a notification), a notification is posted (with a slight delay). `MasterFeedViewController` and `SettingsViewController` are observers. `MasterFeedViewController` will dismiss any `SFSafariViewController`s that are presented, while `SettingsViewController` will dismiss itself.
This commit is contained in:
parent
50a61d6a67
commit
0db88c5f92
@ -210,6 +210,10 @@ 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: {
|
||||
NotificationCenter.default.post(name: .DidLaunchFromExternalAction, object: nil)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(configureContextMenu(_:)), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(didLaunchFromURLContext), name: .DidLaunchFromExternalAction, object: nil)
|
||||
|
||||
refreshControl = UIRefreshControl()
|
||||
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
|
||||
@ -687,6 +688,13 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
present(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func didLaunchFromURLContext() {
|
||||
guard let presentedController = presentedViewController as? SFSafariViewController else {
|
||||
return
|
||||
}
|
||||
presentedController.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: UIContextMenuInteractionDelegate
|
||||
|
@ -11,6 +11,10 @@ import UserNotifications
|
||||
import Account
|
||||
import Zip
|
||||
|
||||
public extension Notification.Name {
|
||||
static let DidLaunchFromExternalAction = Notification.Name("DidLaunchFromExternalAction")
|
||||
}
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
@ -105,6 +109,11 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
guard let context = urlContexts.first else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
NotificationCenter.default.post(name: .DidLaunchFromExternalAction, object: nil)
|
||||
}
|
||||
|
||||
let urlString = context.url.absoluteString
|
||||
|
||||
// Handle the feed: and feeds: schemes
|
||||
@ -202,6 +211,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ class SettingsViewController: UITableViewController {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange), name: .UserDidDeleteAccount, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(activeExtensionPointsDidChange), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(didLaunchFromURLContext), name: .DidLaunchFromExternalAction, object: nil)
|
||||
|
||||
|
||||
tableView.register(UINib(nibName: "SettingsComboTableViewCell", bundle: nil), forCellReuseIdentifier: "SettingsComboTableViewCell")
|
||||
@ -389,6 +390,10 @@ class SettingsViewController: UITableViewController {
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
@objc func didLaunchFromURLContext() {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: OPML Document Picker
|
||||
|
Loading…
x
Reference in New Issue
Block a user