Don't prioritize hashtags or users (IOS-141)

This commit is contained in:
Nathan Mattes 2023-09-18 17:32:01 +02:00
parent dd569fe0ac
commit 3ce8e29244
1 changed files with 5 additions and 8 deletions

View File

@ -37,21 +37,18 @@ extension SearchHistoryViewModel {
do {
let managedObjectContext = self.context.managedObjectContext
let items: [SearchHistoryItem] = try await managedObjectContext.perform {
var users: [SearchHistoryItem] = []
var hashtags: [SearchHistoryItem] = []
var items: [SearchHistoryItem] = []
for record in records {
guard let searchHistory = record.object(in: managedObjectContext) else { continue }
if let user = searchHistory.account {
users.append(.user(.init(objectID: user.objectID)))
items.append(.user(.init(objectID: user.objectID)))
} else if let hashtag = searchHistory.hashtag {
hashtags.append(.hashtag(.init(objectID: hashtag.objectID)))
} else {
continue
items.append(.hashtag(.init(objectID: hashtag.objectID)))
}
}
return users + hashtags
return items
}
let mostRecentItems = Array(items.prefix(10))