mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-25 08:21:40 +01:00
chore(Widget): Fix picked account not desired account
This commit is contained in:
parent
0647cae24a
commit
0e303418d7
@ -84,21 +84,24 @@ private extension FollowersCountWidgetProvider {
|
|||||||
return completion(.unconfigured)
|
return completion(.unconfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let desiredAccount: String = {
|
guard
|
||||||
guard let account = configuration.account else {
|
let desiredAccount = configuration.account ?? authBox.authenticationRecord.object(
|
||||||
return authBox.authenticationRecord.object(in: WidgetExtension.appContext.managedObjectContext)?.user.acct
|
in: WidgetExtension.appContext.managedObjectContext
|
||||||
}
|
)?.user.acct
|
||||||
return account
|
else {
|
||||||
}() else {
|
|
||||||
return completion(.unconfigured)
|
return completion(.unconfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
let resultingAccount = try await WidgetExtension.appContext
|
guard
|
||||||
.apiService
|
let resultingAccount = try await WidgetExtension.appContext
|
||||||
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
.apiService
|
||||||
.value
|
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
||||||
.accounts
|
.value
|
||||||
.first!
|
.accounts
|
||||||
|
.first(where: { $0.acct == desiredAccount })
|
||||||
|
else {
|
||||||
|
return completion(.unconfigured)
|
||||||
|
}
|
||||||
|
|
||||||
let imageData = try await URLSession.shared.data(from: resultingAccount.avatarImageURLWithFallback(domain: authBox.domain)).0
|
let imageData = try await URLSession.shared.data(from: resultingAccount.avatarImageURLWithFallback(domain: authBox.domain)).0
|
||||||
|
|
||||||
|
@ -82,27 +82,31 @@ private extension MultiFollowersCountWidgetProvider {
|
|||||||
return completion(.unconfigured)
|
return completion(.unconfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let desiredAccounts: [String] = {
|
let desiredAccounts: [String]
|
||||||
guard let account = configuration.accounts?.compactMap({ $0 }) else {
|
|
||||||
if let acct = authBox.authenticationRecord.object(in: WidgetExtension.appContext.managedObjectContext)?.user.acct {
|
if let configuredAccounts = configuration.accounts?.compactMap({ $0 }) {
|
||||||
return [acct]
|
desiredAccounts = configuredAccounts
|
||||||
}
|
} else if let currentlyLoggedInAccount = authBox.authenticationRecord.object(
|
||||||
return nil
|
in: WidgetExtension.appContext.managedObjectContext
|
||||||
}
|
)?.user.acct {
|
||||||
return account
|
desiredAccounts = [currentlyLoggedInAccount]
|
||||||
}() else {
|
} else {
|
||||||
return completion(.unconfigured)
|
return completion(.unconfigured)
|
||||||
}
|
}
|
||||||
|
|
||||||
var accounts = [MultiFollowersEntryAccountable]()
|
var accounts = [MultiFollowersEntryAccountable]()
|
||||||
|
|
||||||
for desiredAccount in desiredAccounts {
|
for desiredAccount in desiredAccounts {
|
||||||
let resultingAccount = try await WidgetExtension.appContext
|
guard
|
||||||
.apiService
|
let resultingAccount = try await WidgetExtension.appContext
|
||||||
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
.apiService
|
||||||
.value
|
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
||||||
.accounts
|
.value
|
||||||
.first!
|
.accounts
|
||||||
|
.first(where: { $0.acct == desiredAccount })
|
||||||
|
else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
let imageData = try await URLSession.shared.data(from: resultingAccount.avatarImageURLWithFallback(domain: authBox.domain)).0
|
let imageData = try await URLSession.shared.data(from: resultingAccount.avatarImageURLWithFallback(domain: authBox.domain)).0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user