feat(Widget): Default to currently active user's account in Widget

This commit is contained in:
Marcus Kida 2023-01-26 15:15:59 +01:00
parent 0d69e5ea4d
commit 4e591bcd1c
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
1 changed files with 12 additions and 3 deletions

View File

@ -124,14 +124,23 @@ private extension FollowersProvider {
let authBox = WidgetExtension.appContext
.authenticationService
.mastodonAuthenticationBoxes
.first,
let account = configuration.account
.first
else {
return completion(.unconfigured)
}
guard let desiredAccount: String = {
guard let account = configuration.account else {
return authBox.authenticationRecord.object(in: WidgetExtension.appContext.managedObjectContext)?.user.acct
}
return account
}() else {
return completion(.unconfigured)
}
let resultingAccount = try await WidgetExtension.appContext
.apiService
.search(query: .init(q: account, type: .accounts), authenticationBox: authBox)
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
.value
.accounts
.first!