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 { do {
let managedObjectContext = self.context.managedObjectContext let managedObjectContext = self.context.managedObjectContext
let items: [SearchHistoryItem] = try await managedObjectContext.perform { let items: [SearchHistoryItem] = try await managedObjectContext.perform {
var users: [SearchHistoryItem] = [] var items: [SearchHistoryItem] = []
var hashtags: [SearchHistoryItem] = []
for record in records { for record in records {
guard let searchHistory = record.object(in: managedObjectContext) else { continue } guard let searchHistory = record.object(in: managedObjectContext) else { continue }
if let user = searchHistory.account { 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 { } else if let hashtag = searchHistory.hashtag {
hashtags.append(.hashtag(.init(objectID: hashtag.objectID))) items.append(.hashtag(.init(objectID: hashtag.objectID)))
} else {
continue
} }
} }
return users + hashtags return items
} }
let mostRecentItems = Array(items.prefix(10)) let mostRecentItems = Array(items.prefix(10))