Compare commits
No commits in common. "5414f2329ca832a363f30913baadc736dddeb472" and "288f855e2f693feb11abf5c74671f81d0dfcea03" have entirely different histories.
5414f2329c
...
288f855e2f
|
@ -143,12 +143,9 @@ struct ComposeAutocompleteMentionsView: View {
|
||||||
|
|
||||||
localSearchWorkItem.cancel()
|
localSearchWorkItem.cancel()
|
||||||
|
|
||||||
// dispatch back to the main thread because loadAccounts uses CoreData
|
// if the query has changed, don't bother loading the now-outdated results
|
||||||
DispatchQueue.main.async {
|
if case .mention(query) = uiState.autocompleteState {
|
||||||
// if the query has changed, don't bother loading the now-outdated results
|
self.loadAccounts(accounts.map { .pachyderm($0) }, query: query)
|
||||||
if case .mention(query) = uiState.autocompleteState {
|
|
||||||
self.loadAccounts(accounts.map { .pachyderm($0) }, query: query)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,20 +161,8 @@ struct ComposeAutocompleteMentionsView: View {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
.filter(\.1.matched)
|
.filter(\.1.matched)
|
||||||
.map { (account, res) -> (EitherAccount, Int) in
|
// todo: it would be nice to prioritize followee/follower accounts, but relationships aren't cached
|
||||||
// give higher weight to accounts that the user follows or is followed by
|
.sorted { $0.1.score > $1.1.score }
|
||||||
var score = res.score
|
|
||||||
if let relationship = mastodonController.persistentContainer.relationship(forAccount: account.id) {
|
|
||||||
if relationship.following {
|
|
||||||
score += 3
|
|
||||||
}
|
|
||||||
if relationship.followedBy {
|
|
||||||
score += 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (account, score)
|
|
||||||
}
|
|
||||||
.sorted { $0.1 > $1.1 }
|
|
||||||
.map(\.0)
|
.map(\.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import Pachyderm
|
|
||||||
|
|
||||||
class MyProfileViewController: ProfileViewController {
|
class MyProfileViewController: ProfileViewController {
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ class MyProfileViewController: ProfileViewController {
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.accountID = account.id
|
self.accountID = account.id
|
||||||
self.setAvatarTabBarImage(account: account)
|
self.setAvatarTabBarImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +38,12 @@ class MyProfileViewController: ProfileViewController {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setAvatarTabBarImage<Account: AccountProtocol>(account: Account) {
|
private func setAvatarTabBarImage() {
|
||||||
|
guard let id = mastodonController.account?.id,
|
||||||
|
let account = mastodonController.persistentContainer.account(for: id) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in
|
_ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in
|
||||||
guard let self = self, let data = data, let image = UIImage(data: data) else { return }
|
guard let self = self, let data = data, let image = UIImage(data: data) else { return }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
@ -57,12 +61,7 @@ class MyProfileViewController: ProfileViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func preferencesChanged() {
|
@objc private func preferencesChanged() {
|
||||||
guard let id = mastodonController.account?.id,
|
setAvatarTabBarImage()
|
||||||
let account = mastodonController.persistentContainer.account(for: id) else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setAvatarTabBarImage(account: account)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Interaction
|
// MARK: - Interaction
|
||||||
|
|
Loading…
Reference in New Issue