Use accounts for shortcut-extension (IOS-192)
This is broken atm, see #1204
This commit is contained in:
parent
58501da5fa
commit
c3d40d260d
|
@ -59,7 +59,7 @@ extension SendPostIntentHandler: SendPostIntentHandling {
|
||||||
}
|
}
|
||||||
mastodonAuthentications = [authentication]
|
mastodonAuthentications = [authentication]
|
||||||
} else {
|
} else {
|
||||||
mastodonAuthentications = try accounts.mastodonAuthentication(in: managedObjectContext)
|
mastodonAuthentications = try accounts.mastodonAuthentication()
|
||||||
}
|
}
|
||||||
|
|
||||||
let authenticationBoxes = mastodonAuthentications.map { authentication in
|
let authenticationBoxes = mastodonAuthentications.map { authentication in
|
||||||
|
@ -149,7 +149,7 @@ extension SendPostIntentHandler: SendPostIntentHandling {
|
||||||
}
|
}
|
||||||
|
|
||||||
func provideAccountsOptionsCollection(for intent: SendPostIntent) async throws -> INObjectCollection<Account> {
|
func provideAccountsOptionsCollection(for intent: SendPostIntent) async throws -> INObjectCollection<Account> {
|
||||||
let accounts = try await Account.fetch(in: managedObjectContext)
|
let accounts = try await Account.fetch()
|
||||||
return .init(items: accounts)
|
return .init(items: accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,34 +14,29 @@ import MastodonCore
|
||||||
extension Account {
|
extension Account {
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
static func fetch(in managedObjectContext: NSManagedObjectContext) async throws -> [Account] {
|
static func fetch() async throws -> [Account] {
|
||||||
// get accounts
|
let accounts = AuthenticationServiceProvider.shared.authentications.compactMap { mastodonAuthentication -> Account? in
|
||||||
let accounts: [Account] = try await managedObjectContext.perform {
|
guard let authenticatedAccount = mastodonAuthentication.account() else {
|
||||||
let results = AuthenticationServiceProvider.shared.authentications
|
return nil
|
||||||
let accounts = results.compactMap { mastodonAuthentication -> Account? in
|
|
||||||
guard let user = mastodonAuthentication.user(in: managedObjectContext) else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
let account = Account(
|
|
||||||
identifier: mastodonAuthentication.identifier.uuidString,
|
|
||||||
display: user.displayNameWithFallback,
|
|
||||||
subtitle: user.acctWithDomain,
|
|
||||||
image: user.avatarImageURL().flatMap { INImage(url: $0) }
|
|
||||||
)
|
|
||||||
account.name = user.displayNameWithFallback
|
|
||||||
account.username = user.acctWithDomain
|
|
||||||
return account
|
|
||||||
}
|
}
|
||||||
return accounts
|
let account = Account(
|
||||||
} // end managedObjectContext.perform
|
identifier: mastodonAuthentication.identifier.uuidString,
|
||||||
|
display: authenticatedAccount.displayNameWithFallback,
|
||||||
|
subtitle: authenticatedAccount.acctWithDomain,
|
||||||
|
image: authenticatedAccount.avatarImageURL().flatMap { INImage(url: $0) }
|
||||||
|
)
|
||||||
|
account.name = authenticatedAccount.displayNameWithFallback
|
||||||
|
account.username = authenticatedAccount.acctWithDomain
|
||||||
|
return account
|
||||||
|
}
|
||||||
|
|
||||||
return accounts
|
return accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Array where Element == Account {
|
extension Array where Element == Account {
|
||||||
func mastodonAuthentication(in managedObjectContext: NSManagedObjectContext) throws -> [MastodonAuthentication] {
|
func mastodonAuthentication() throws -> [MastodonAuthentication] {
|
||||||
let identifiers = self
|
let identifiers = self
|
||||||
.compactMap { $0.identifier }
|
.compactMap { $0.identifier }
|
||||||
.compactMap { UUID(uuidString: $0) }
|
.compactMap { UUID(uuidString: $0) }
|
||||||
|
|
Loading…
Reference in New Issue