1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-12 16:46:32 +01:00
mastodon-app-ufficiale-ipho.../MastodonIntent/Handler/MultiFollowersCountIntentHandler.swift

28 lines
1023 B
Swift
Raw Normal View History

// Copyright © 2023 Mastodon gGmbH. All rights reserved.
import Foundation
import Intents
import MastodonCore
import MastodonSDK
import MastodonLocalization
class MultiFollowersCountIntentHandler: INExtension, MultiFollowersCountIntentHandling {
func provideAccountsOptionsCollection(for intent: MultiFollowersCountIntent, searchTerm: String?) async throws -> INObjectCollection<NSString> {
guard
let searchTerm = searchTerm,
let authenticationBox = WidgetExtension.appContext
.authenticationService
.mastodonAuthenticationBoxes
.first
else {
return INObjectCollection(items: [])
}
let results = try await WidgetExtension.appContext
.apiService
.search(query: .init(q: searchTerm), authenticationBox: authenticationBox)
return INObjectCollection(items: results.value.accounts.map { $0.acctWithDomainIfMissing(authenticationBox.domain) as NSString })
}
}