Broken scene activation conditions stuff
This commit is contained in:
parent
2f6d0ae07c
commit
9d22d4ef35
|
@ -49,6 +49,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
if let activity = activity {
|
||||
setupUI(from: activity)
|
||||
}
|
||||
setupSceneActivationConditions()
|
||||
}
|
||||
} else {
|
||||
createLoginUI()
|
||||
|
@ -136,6 +137,17 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
window!.rootViewController = AppSplitViewController(fervorController: fervorController)
|
||||
}
|
||||
|
||||
private func setupSceneActivationConditions() {
|
||||
guard let account = fervorController?.account else {
|
||||
return
|
||||
}
|
||||
let scene = self.window!.windowScene!
|
||||
// todo: why the fuck doesn't this work
|
||||
// it always picks the most recently focused window
|
||||
scene.activationConditions.prefersToActivateForTargetContentIdentifierPredicate = NSPredicate(format: "self == '\(account.id.base64EncodedString())'")
|
||||
scene.activationConditions.canActivateForTargetContentIdentifierPredicate = NSPredicate(value: false)
|
||||
}
|
||||
|
||||
private func syncFromServer() {
|
||||
guard let fervorController = fervorController else {
|
||||
return
|
||||
|
@ -179,6 +191,7 @@ extension SceneDelegate: LoginViewControllerDelegate {
|
|||
|
||||
createAppUI()
|
||||
syncFromServer()
|
||||
setupSceneActivationConditions()
|
||||
|
||||
UIMenuSystem.main.setNeedsRebuild()
|
||||
}
|
||||
|
|
|
@ -204,9 +204,9 @@ class HomeViewController: UIViewController {
|
|||
vc.delegate = itemsDelegate
|
||||
switch item {
|
||||
case .all:
|
||||
vc.userActivity = .readAll()
|
||||
vc.userActivity = .readAll(account: fervorController.account!)
|
||||
case .unread:
|
||||
vc.userActivity = .readUnread()
|
||||
vc.userActivity = .readUnread(account: fervorController.account!)
|
||||
case .group(let group):
|
||||
break
|
||||
case .feed(let feed):
|
||||
|
|
|
@ -16,7 +16,12 @@ extension NSUserActivity {
|
|||
static let readAllType = "net.shadowfacts.Reader.activity.read-all"
|
||||
|
||||
func accountID() -> Data? {
|
||||
if [NSUserActivity.addAccountType].contains(self.activityType),
|
||||
let types = [
|
||||
NSUserActivity.activateAccountType,
|
||||
NSUserActivity.readUnreadType,
|
||||
NSUserActivity.readAllType,
|
||||
]
|
||||
if types.contains(self.activityType),
|
||||
let id = self.userInfo?["accountID"] as? Data {
|
||||
return id
|
||||
} else {
|
||||
|
@ -40,19 +45,27 @@ extension NSUserActivity {
|
|||
return activity
|
||||
}
|
||||
|
||||
static func readUnread() -> NSUserActivity {
|
||||
static func readUnread(account: LocalData.Account) -> NSUserActivity {
|
||||
let activity = NSUserActivity(activityType: readUnreadType)
|
||||
activity.isEligibleForHandoff = true
|
||||
activity.isEligibleForPrediction = true
|
||||
activity.title = "Show unread articles"
|
||||
activity.userInfo = [
|
||||
"accountID": account.id
|
||||
]
|
||||
activity.targetContentIdentifier = account.id.base64EncodedString()
|
||||
return activity
|
||||
}
|
||||
|
||||
static func readAll() -> NSUserActivity {
|
||||
static func readAll(account: LocalData.Account) -> NSUserActivity {
|
||||
let activity = NSUserActivity(activityType: readAllType)
|
||||
activity.isEligibleForHandoff = true
|
||||
activity.isEligibleForPrediction = true
|
||||
activity.title = "Show all articles"
|
||||
activity.userInfo = [
|
||||
"accountID": account.id
|
||||
]
|
||||
activity.targetContentIdentifier = account.id.base64EncodedString()
|
||||
return activity
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue