fix(Widget): User lookup for widget does not yield correct result
This commit is contained in:
parent
e88dea0034
commit
736c3b515f
|
@ -30,15 +30,6 @@ class FollowersCountIntentHandler: INExtension, FollowersCountIntentHandling {
|
|||
.apiService
|
||||
.search(query: .init(q: searchTerm), authenticationBox: authenticationBox)
|
||||
|
||||
return INObjectCollection(items: results.value.accounts.map { $0.acctWithDomain(localDomain: authenticationBox.domain) as NSString })
|
||||
}
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Account {
|
||||
func acctWithDomain(localDomain: String) -> String {
|
||||
guard acct.contains("@") else {
|
||||
return "\(acct)@\(localDomain)"
|
||||
}
|
||||
return acct
|
||||
return INObjectCollection(items: results.value.accounts.map { $0.acctWithDomainIfMissing(authenticationBox.domain) as NSString })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ class MultiFollowersCountIntentHandler: INExtension, MultiFollowersCountIntentHa
|
|||
.apiService
|
||||
.search(query: .init(q: searchTerm), authenticationBox: authenticationBox)
|
||||
|
||||
return INObjectCollection(items: results.value.accounts.map { $0.acctWithDomain(localDomain: authenticationBox.domain) as NSString })
|
||||
return INObjectCollection(items: results.value.accounts.map { $0.acctWithDomainIfMissing(authenticationBox.domain) as NSString })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,13 @@ extension Mastodon.Entity {
|
|||
case muteExpiresAt = "mute_expires_at"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Account {
|
||||
public func acctWithDomainIfMissing(_ localDomain: String) -> String {
|
||||
guard acct.contains("@") else {
|
||||
return "\(acct)@\(localDomain)"
|
||||
}
|
||||
return acct
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ private extension FollowersCountWidgetProvider {
|
|||
guard
|
||||
let desiredAccount = configuration.account ?? authBox.authenticationRecord.object(
|
||||
in: WidgetExtension.appContext.managedObjectContext
|
||||
)?.user.acct
|
||||
)?.user.acctWithDomain
|
||||
else {
|
||||
return completion(.unconfigured)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ private extension FollowersCountWidgetProvider {
|
|||
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
||||
.value
|
||||
.accounts
|
||||
.first(where: { $0.acct == desiredAccount })
|
||||
.first(where: { $0.acctWithDomainIfMissing(authBox.domain) == desiredAccount })
|
||||
else {
|
||||
return completion(.unconfigured)
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ private extension MultiFollowersCountWidgetProvider {
|
|||
desiredAccounts = configuredAccounts
|
||||
} else if let currentlyLoggedInAccount = authBox.authenticationRecord.object(
|
||||
in: WidgetExtension.appContext.managedObjectContext
|
||||
)?.user.acct {
|
||||
)?.user.acctWithDomain {
|
||||
desiredAccounts = [currentlyLoggedInAccount]
|
||||
} else {
|
||||
return completion(.unconfigured)
|
||||
|
@ -103,7 +103,7 @@ private extension MultiFollowersCountWidgetProvider {
|
|||
.search(query: .init(q: desiredAccount, type: .accounts), authenticationBox: authBox)
|
||||
.value
|
||||
.accounts
|
||||
.first(where: { $0.acct == desiredAccount })
|
||||
.first(where: { $0.acctWithDomainIfMissing(authBox.domain) == desiredAccount })
|
||||
else {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue