Compare commits

...

6 Commits

Author SHA1 Message Date
Shadowfacts c65b69cfbd Update home unread counts after sync 2022-03-08 12:00:08 -05:00
Shadowfacts 533bc025f3 Add feed/group user activities 2022-03-07 23:16:35 -05:00
Shadowfacts 9d22d4ef35 Broken scene activation conditions stuff 2022-03-07 23:06:05 -05:00
Shadowfacts 2f6d0ae07c Add user activities for read all/unread 2022-03-07 22:22:11 -05:00
Shadowfacts 7f5006c629 Use deterministic ids for accounts 2022-03-07 21:12:43 -05:00
Shadowfacts dec7a6e57f Swift concurrency stuff
i don't know if any of this is right, but it seems like it works so...
2022-03-06 15:08:42 -05:00
17 changed files with 337 additions and 132 deletions

View File

@ -7,7 +7,7 @@
import Foundation
public struct ClientRegistration: Decodable {
public struct ClientRegistration: Decodable, Sendable {
public let clientID: String
public let clientSecret: String

View File

@ -5,9 +5,9 @@
// Created by Shadowfacts on 10/29/21.
//
import Foundation
@preconcurrency import Foundation
public struct Feed: Decodable {
public struct Feed: Decodable, Sendable {
public let id: FervorID
public let title: String
public let url: URL?

View File

@ -5,13 +5,13 @@
// Created by Shadowfacts on 11/25/21.
//
import Foundation
@preconcurrency import Foundation
public class FervorClient {
public actor FervorClient: Sendable {
let instanceURL: URL
let session: URLSession
public var accessToken: String?
private let instanceURL: URL
private let session: URLSession
public private(set) var accessToken: String?
private let decoder: JSONDecoder = {
let d = JSONDecoder()
@ -81,7 +81,9 @@ public class FervorClient {
"client_id": clientID,
"client_secret": clientSecret,
])
return try await performRequest(request)
let result: Token = try await performRequest(request)
self.accessToken = result.accessToken
return result
}
public func groups() async throws -> [Group] {

View File

@ -5,9 +5,9 @@
// Created by Shadowfacts on 10/29/21.
//
import Foundation
@preconcurrency import Foundation
public struct Group: Decodable {
public struct Group: Decodable, Sendable {
public let id: FervorID
public let title: String
public let feedIDs: [FervorID]

View File

@ -5,9 +5,9 @@
// Created by Shadowfacts on 10/29/21.
//
import Foundation
@preconcurrency import Foundation
public struct Instance: Decodable {
public struct Instance: Decodable, Sendable {
public let name: String
public let url: URL
public let version: String

View File

@ -5,9 +5,9 @@
// Created by Shadowfacts on 10/29/21.
//
import Foundation
@preconcurrency import Foundation
public struct Item: Decodable {
public struct Item: Decodable, Sendable {
public let id: FervorID
public let feedID: FervorID
public let title: String?

View File

@ -5,9 +5,9 @@
// Created by Shadowfacts on 1/9/22.
//
import Foundation
@preconcurrency import Foundation
public struct ItemsSyncUpdate: Decodable {
public struct ItemsSyncUpdate: Decodable, Sendable {
public let syncTimestamp: Date
public let delete: [FervorID]

View File

@ -7,10 +7,11 @@
import Foundation
public struct Token: Decodable {
public struct Token: Codable, Sendable {
public let accessToken: String
public let expiresIn: Int?
public let refreshToken: String?
public let owner: String?
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
@ -18,11 +19,21 @@ public struct Token: Decodable {
self.accessToken = try container.decode(String.self, forKey: .accessToken)
self.expiresIn = try container.decodeIfPresent(Int.self, forKey: .expiresIn)
self.refreshToken = try container.decodeIfPresent(String.self, forKey: .refreshToken)
self.owner = try container.decodeIfPresent(String.self, forKey: .owner)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(accessToken, forKey: .accessToken)
try container.encodeIfPresent(expiresIn, forKey: .expiresIn)
try container.encodeIfPresent(refreshToken, forKey: .refreshToken)
try container.encodeIfPresent(owner, forKey: .owner)
}
private enum CodingKeys: String, CodingKey {
case accessToken = "access_token"
case expiresIn = "expires_in"
case refreshToken = "refresh_token"
case owner
}
}

View File

@ -9,7 +9,8 @@ import CoreData
import Fervor
import OSLog
class PersistentContainer: NSPersistentContainer {
// todo: is this actually sendable?
class PersistentContainer: NSPersistentContainer, @unchecked Sendable {
private static let managedObjectModel: NSManagedObjectModel = {
let url = Bundle.main.url(forResource: "Reader", withExtension: "momd")!
@ -23,14 +24,14 @@ class PersistentContainer: NSPersistentContainer {
return context
}()
private weak var fervorController: FervorController?
weak var fervorController: FervorController?
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PersistentContainer")
init(account: LocalData.Account, fervorController: FervorController) {
self.fervorController = fervorController
super.init(name: "\(account.id)", managedObjectModel: PersistentContainer.managedObjectModel)
init(account: LocalData.Account) {
// slashes the base64 string turn into subdirectories which we don't want
let name = account.id.base64EncodedString().replacingOccurrences(of: "/", with: "_")
super.init(name: name, managedObjectModel: PersistentContainer.managedObjectModel)
loadPersistentStores { description, error in
if let error = error {
@ -40,7 +41,7 @@ class PersistentContainer: NSPersistentContainer {
}
@MainActor
private func saveViewContext() async throws {
func saveViewContext() throws {
if viewContext.hasChanges {
try viewContext.save()
}

View File

@ -5,12 +5,12 @@
// Created by Shadowfacts on 11/25/21.
//
import Foundation
@preconcurrency import Foundation
import Fervor
import OSLog
@preconcurrency import OSLog
import Combine
class FervorController {
actor FervorController {
static let oauthRedirectURI = URL(string: "frenzy://oauth-callback")!
@ -19,36 +19,40 @@ class FervorController {
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "FervorController")
let client: FervorClient
private(set) var account: LocalData.Account?
nonisolated let account: LocalData.Account?
private(set) var clientID: String?
private(set) var clientSecret: String?
private(set) var accessToken: String?
private(set) var token: Token?
private(set) var persistentContainer: PersistentContainer!
nonisolated let persistentContainer: PersistentContainer!
@Published private(set) var syncState = SyncState.done
nonisolated let syncState = PassthroughSubject<SyncState, Never>()
private var lastSyncState = SyncState.done
private var cancellables = Set<AnyCancellable>()
init(instanceURL: URL) {
init(instanceURL: URL, account: LocalData.Account?) async {
self.instanceURL = instanceURL
self.client = FervorClient(instanceURL: instanceURL, accessToken: nil)
self.client = FervorClient(instanceURL: instanceURL, accessToken: account?.token.accessToken)
self.account = account
self.clientID = account?.clientID
self.clientSecret = account?.clientSecret
if let account = account {
self.persistentContainer = PersistentContainer(account: account)
} else {
self.persistentContainer = nil
}
persistentContainer?.fervorController = self
}
convenience init(account: LocalData.Account) {
self.init(instanceURL: account.instanceURL)
self.account = account
self.clientID = account.clientID
self.clientSecret = account.clientSecret
self.accessToken = account.accessToken
self.client.accessToken = account.accessToken
self.persistentContainer = PersistentContainer(account: account, fervorController: self)
convenience init(account: LocalData.Account) async {
await self.init(instanceURL: account.instanceURL, account: account)
}
private func setSyncState(_ state: SyncState) {
DispatchQueue.main.async {
self.syncState = state
}
lastSyncState = state
syncState.send(state)
}
func register() async throws -> ClientRegistration {
@ -59,13 +63,11 @@ class FervorController {
}
func getToken(authCode: String) async throws {
let token = try await client.token(authCode: authCode, redirectURI: FervorController.oauthRedirectURI, clientID: clientID!, clientSecret: clientSecret!)
client.accessToken = token.accessToken
accessToken = token.accessToken
token = try await client.token(authCode: authCode, redirectURI: FervorController.oauthRedirectURI, clientID: clientID!, clientSecret: clientSecret!)
}
func syncAll() async throws {
guard syncState == .done else {
guard lastSyncState == .done else {
return
}
// always return to .done, even if we throw and stop syncing early
@ -138,7 +140,7 @@ class FervorController {
func markItem(_ item: Item, read: Bool) async {
item.read = read
do {
let f = item.read ? client.read(item:) : client.unread(item:)
let f = read ? client.read(item:) : client.unread(item:)
_ = try await f(item.id!)
item.needsReadStateSync = false
} catch {
@ -146,12 +148,10 @@ class FervorController {
item.needsReadStateSync = true
}
if persistentContainer.viewContext.hasChanges {
do {
try persistentContainer.viewContext.save()
} catch {
logger.error("Failed to save view context: \(String(describing: error), privacy: .public)")
}
do {
try self.persistentContainer.saveViewContext()
} catch {
logger.error("Failed to save view context: \(String(describing: error), privacy: .public)")
}
}

View File

@ -4,6 +4,10 @@
<dict>
<key>NSUserActivityTypes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.read-unread</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.read-all</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.read-feed</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.read-group</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.preferences</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.add-account</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.activate-account</string>

View File

@ -6,6 +6,8 @@
//
import Foundation
import Fervor
import CryptoKit
struct LocalData {
@ -28,15 +30,12 @@ struct LocalData {
}
}
static var mostRecentAccountID: UUID? {
static var mostRecentAccountID: Data? {
get {
guard let str = UserDefaults.standard.string(forKey: "mostRecentAccountID") else {
return nil
}
return UUID(uuidString: str)
return UserDefaults.standard.data(forKey: "mostRecentAccountID")
}
set {
UserDefaults.standard.set(newValue?.uuidString, forKey: "mostRecentAccountID")
UserDefaults.standard.set(newValue, forKey: "mostRecentAccountID")
}
}
@ -44,23 +43,32 @@ struct LocalData {
guard let id = mostRecentAccountID else {
return nil
}
return account(with: id)
}
static func account(with id: Data) -> Account? {
return accounts.first(where: { $0.id == id })
}
struct Account: Codable {
let id: UUID
let id: Data
let instanceURL: URL
let clientID: String
let clientSecret: String
let accessToken: String
// todo: refresh tokens
let token: Token
init(instanceURL: URL, clientID: String, clientSecret: String, accessToken: String) {
self.id = UUID()
init(instanceURL: URL, clientID: String, clientSecret: String, token: Token) {
// we use a hash of instance host and account id rather than random ids so that
// user activites can uniquely identify accounts across devices
var hasher = SHA256()
hasher.update(data: instanceURL.host!.data(using: .utf8)!)
hasher.update(data: token.owner!.data(using: .utf8)!)
self.id = Data(hasher.finalize())
self.instanceURL = instanceURL
self.clientID = clientID
self.clientSecret = clientSecret
self.accessToken = accessToken
self.token = token
}
}

View File

@ -5,6 +5,7 @@
// Created by Shadowfacts on 10/29/21.
//
@preconcurrency import Foundation
import UIKit
import OSLog
@ -26,22 +27,32 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window = UIWindow(windowScene: windowScene)
window!.tintColor = .appTintColor
let activity = connectionOptions.userActivities.first
var activity = connectionOptions.userActivities.first
var account = LocalData.mostRecentAccount()
if activity?.activityType == NSUserActivity.addAccountType {
let loginVC = LoginViewController()
loginVC.delegate = self
window!.rootViewController = loginVC
} else if activity?.activityType == NSUserActivity.activateAccountType,
let account = LocalData.accounts.first(where: { $0.id.uuidString == activity!.userInfo?["accountID"] as? String }) {
fervorController = FervorController(account: account)
createAppUI()
} else if let account = LocalData.mostRecentAccount() {
fervorController = FervorController(account: account)
createAppUI()
account = nil
} else if let id = activity?.accountID() {
account = LocalData.account(with: id)
if account == nil {
activity = nil
logger.log("Missing account for activity, not restoring")
}
}
if let account = account {
Task { @MainActor [activity] in
fervorController = await FervorController(account: account)
syncFromServer()
createAppUI()
if let activity = activity {
setupUI(from: activity)
}
setupSceneActivationConditions()
}
} else {
let loginVC = LoginViewController()
loginVC.delegate = self
window!.rootViewController = loginVC
createLoginUI()
}
#if targetEnvironment(macCatalyst)
@ -97,10 +108,64 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// to restore the scene back to its current state.
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
setupUI(from: userActivity)
}
private func setupUI(from activity: NSUserActivity) {
guard let split = window?.rootViewController as? AppSplitViewController else {
logger.error("Failed to setup UI for user activity: missing split VC")
return
}
switch activity.activityType {
case NSUserActivity.readUnreadType:
split.selectHomeItem(.unread)
case NSUserActivity.readAllType:
split.selectHomeItem(.all)
case NSUserActivity.readFeedType:
guard let feedID = activity.feedID() else {
break
}
let req = Feed.fetchRequest()
req.predicate = NSPredicate(format: "id = %@", feedID)
if let feed = try? fervorController.persistentContainer.viewContext.fetch(req).first {
split.selectHomeItem(.feed(feed))
}
case NSUserActivity.readGroupType:
guard let groupID = activity.groupID() else {
break
}
let req = Group.fetchRequest()
req.predicate = NSPredicate(format: "id = %@", groupID)
if let group = try? fervorController.persistentContainer.viewContext.fetch(req).first {
split.selectHomeItem(.group(group))
}
default:
break
}
}
private func createLoginUI() {
let vc = LoginViewController()
vc.delegate = self
window!.rootViewController = vc
}
private func createAppUI() {
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
@ -125,9 +190,9 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}
}
func switchToAccount(_ account: LocalData.Account) {
func switchToAccount(_ account: LocalData.Account) async {
LocalData.mostRecentAccountID = account.id
fervorController = FervorController(account: account)
fervorController = await FervorController(account: account)
createAppUI()
syncFromServer()
}
@ -136,15 +201,18 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
extension SceneDelegate: LoginViewControllerDelegate {
func didLogin(with controller: FervorController) {
let account = LocalData.Account(instanceURL: controller.instanceURL, clientID: controller.clientID!, clientSecret: controller.clientSecret!, accessToken: controller.accessToken!)
LocalData.accounts.append(account)
LocalData.mostRecentAccountID = account.id
fervorController = FervorController(account: account)
createAppUI()
syncFromServer()
UIMenuSystem.main.setNeedsRebuild()
Task { @MainActor in
let account = LocalData.Account(instanceURL: controller.instanceURL, clientID: await controller.clientID!, clientSecret: await controller.clientSecret!, token: await controller.token!)
LocalData.accounts.append(account)
LocalData.mostRecentAccountID = account.id
fervorController = await FervorController(account: account)
createAppUI()
syncFromServer()
setupSceneActivationConditions()
UIMenuSystem.main.setNeedsRebuild()
}
}
}

View File

@ -53,6 +53,18 @@ class AppSplitViewController: UISplitViewController {
let nav = AppNavigationController(rootViewController: home)
setViewController(nav, for: .compact)
}
func selectHomeItem(_ item: HomeViewController.Item) {
let column: Column
if traitCollection.horizontalSizeClass == .compact {
column = .compact
} else {
column = .primary
}
let nav = viewController(for: column) as! UINavigationController
let home = nav.viewControllers.first! as! HomeViewController
home.selectItem(item)
}
}
@ -65,7 +77,9 @@ extension AppSplitViewController: ItemsViewControllerDelegate {
extension AppSplitViewController: HomeViewControllerDelegate {
func switchToAccount(_ account: LocalData.Account) {
if let delegate = view.window?.windowScene?.delegate as? SceneDelegate {
delegate.switchToAccount(account)
Task { @MainActor in
await delegate.switchToAccount(account)
}
}
}
}

View File

@ -93,7 +93,7 @@ class HomeViewController: UIViewController {
feedResultsController.delegate = self
try! feedResultsController.performFetch()
fervorController.$syncState
fervorController.syncState
.debounce(for: .milliseconds(250), scheduler: RunLoop.main, options: nil)
.sink { [unowned self] in
self.syncStateChanged($0)
@ -149,8 +149,16 @@ class HomeViewController: UIViewController {
}
private func syncStateChanged(_ newState: FervorController.SyncState) {
if newState == .done && syncStateView == nil {
return
if newState == .done {
// update unread counts for visible items
var snapshot = dataSource.snapshot()
snapshot.reconfigureItems(snapshot.itemIdentifiers)
dataSource.apply(snapshot, animatingDifferences: false)
if syncStateView == nil {
// no sync state view, nothing further to update
return
}
}
func updateView(_ syncStateView: SyncStateView) {
@ -198,6 +206,28 @@ class HomeViewController: UIViewController {
}
}
private func itemsViewController(for item: Item) -> ItemsViewController {
let vc = ItemsViewController(fetchRequest: item.idFetchRequest, fervorController: fervorController)
vc.title = item.title
vc.delegate = itemsDelegate
switch item {
case .all:
vc.userActivity = .readAll(account: fervorController.account!)
case .unread:
vc.userActivity = .readUnread(account: fervorController.account!)
case .group(let group):
vc.userActivity = .readGroup(group, account: fervorController.account!)
case .feed(let feed):
vc.userActivity = .readFeed(feed, account: fervorController.account!)
}
return vc
}
func selectItem(_ item: Item) {
navigationController!.popToRootViewController(animated: false)
navigationController!.pushViewController(itemsViewController(for: item), animated: false)
}
}
extension HomeViewController {
@ -236,21 +266,6 @@ extension HomeViewController {
}
}
var fetchRequest: NSFetchRequest<Reader.Item> {
let req = Reader.Item.fetchRequest()
switch self {
case .unread:
req.predicate = NSPredicate(format: "read = NO")
case .all:
break
case .group(let group):
req.predicate = NSPredicate(format: "feed in %@", group.feeds!)
case .feed(let feed):
req.predicate = NSPredicate(format: "feed = %@", feed)
}
return req
}
var idFetchRequest: NSFetchRequest<NSManagedObjectID> {
let req = NSFetchRequest<NSManagedObjectID>(entityName: "Item")
req.resultType = .managedObjectIDResultType
@ -307,10 +322,7 @@ extension HomeViewController: UICollectionViewDelegate {
guard let item = dataSource.itemIdentifier(for: indexPath) else {
return
}
let vc = ItemsViewController(fetchRequest: item.idFetchRequest, fervorController: fervorController)
vc.title = item.title
vc.delegate = itemsDelegate
show(vc, sender: nil)
show(itemsViewController(for: item), sender: nil)
UISelectionFeedbackGenerator().selectionChanged()
}
@ -318,8 +330,8 @@ extension HomeViewController: UICollectionViewDelegate {
guard let item = dataSource.itemIdentifier(for: indexPath) else {
return nil
}
return UIContextMenuConfiguration(identifier: nil, previewProvider: {
return ItemsViewController(fetchRequest: item.idFetchRequest, fervorController: self.fervorController)
return UIContextMenuConfiguration(identifier: nil, previewProvider: { [unowned self] in
return self.itemsViewController(for: item)
}, actionProvider: nil)
}

View File

@ -5,6 +5,7 @@
// Created by Shadowfacts on 11/25/21.
//
@preconcurrency import Foundation
import UIKit
import AuthenticationServices
import Fervor
@ -72,7 +73,7 @@ class LoginViewController: UIViewController {
textField.isEnabled = false
activityIndicator.startAnimating()
let controller = FervorController(instanceURL: components.url!)
let controller = await FervorController(instanceURL: components.url!, account: nil)
let registration: ClientRegistration
do {
@ -99,16 +100,16 @@ class LoginViewController: UIViewController {
let components = URLComponents(url: callbackURL!, resolvingAgainstBaseURL: false)
guard let codeItem = components?.queryItems?.first(where: { $0.name == "code" }),
let codeValue = codeItem.value else {
DispatchQueue.main.async {
let alert = UIAlertController(title: "Unable to retrieve authorization code", message: error?.localizedDescription ?? "Unknown Error", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alert, animated: true)
self.textField.isEnabled = true
self.activityIndicator.stopAnimating()
}
return
}
Task { @MainActor in
let alert = UIAlertController(title: "Unable to retrieve authorization code", message: error?.localizedDescription ?? "Unknown Error", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alert, animated: true)
self.textField.isEnabled = true
self.activityIndicator.stopAnimating()
}
return
}
Task { @MainActor in
do {
try await controller.getToken(authCode: codeValue)

View File

@ -12,7 +12,41 @@ extension NSUserActivity {
static let preferencesType = "net.shadowfacts.Reader.activity.preferences"
static let addAccountType = "net.shadowfacts.Reader.activity.add-account"
static let activateAccountType = "net.shadowfacts.Reader.activity.activate-account"
static let readUnreadType = "net.shadowfacts.Reader.activity.read-unread"
static let readAllType = "net.shadowfacts.Reader.activity.read-all"
static let readFeedType = "net.shadowfacts.Reader.activity.read-feed"
static let readGroupType = "net.shadowfacts.Reader.activity.read-group"
func accountID() -> Data? {
let types = [
NSUserActivity.activateAccountType,
NSUserActivity.readUnreadType,
NSUserActivity.readAllType,
]
if types.contains(self.activityType),
let id = self.userInfo?["accountID"] as? Data {
return id
} else {
return nil
}
}
func feedID() -> String? {
if activityType == NSUserActivity.readFeedType {
return userInfo?["feedID"] as? String
} else {
return nil
}
}
func groupID() -> String? {
if activityType == NSUserActivity.readGroupType {
return userInfo?["groupID"] as? String
} else {
return nil
}
}
static func preferences() -> NSUserActivity {
return NSUserActivity(activityType: preferencesType)
}
@ -24,9 +58,59 @@ extension NSUserActivity {
static func activateAccount(_ account: LocalData.Account) -> NSUserActivity {
let activity = NSUserActivity(activityType: activateAccountType)
activity.userInfo = [
"accountID": account.id.uuidString
"accountID": account.id,
]
return activity
}
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(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
}
static func readFeed(_ feed: Feed, account: LocalData.Account) -> NSUserActivity {
let activity = NSUserActivity(activityType: readFeedType)
activity.isEligibleForHandoff = true
activity.isEligibleForPrediction = true
activity.title = "Show articles from \(feed.title!)"
activity.userInfo = [
"accountID": account.id,
"feedID": feed.id!
]
activity.targetContentIdentifier = account.id.base64EncodedString()
return activity
}
static func readGroup(_ group: Group, account: LocalData.Account) -> NSUserActivity {
let activity = NSUserActivity(activityType: readGroupType)
activity.isEligibleForHandoff = true
activity.isEligibleForPrediction = true
activity.title = "Show articles from \(group.title)"
activity.userInfo = [
"accountID": account.id,
"groupID": group.id!
]
activity.targetContentIdentifier = account.id.base64EncodedString()
return activity
}
}