Skip to content

Commit

Permalink
Optimized search view rendering (#695)
Browse files Browse the repository at this point in the history
Commit:
fb3ebb3 [fb3ebb3]
  • Loading branch information
boscojwho committed Oct 11, 2023
1 parent 5e91e98 commit 46339b0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Mlem/Models/Trackers/RecentSearchesTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ class RecentSearchesTracker: ObservableObject {
func reloadRecentSearches(accountId: String?) async throws {
defer { hasLoaded = true }

recentSearches = .init()
if let accountId {
let identifiers = persistenceRepository.loadRecentSearches(for: accountId)
var newSearches: [AnyContentModel] = .init()

for id in identifiers {
print(id.contentType, id.contentId)
switch id.contentType {
case .post:
break
case .community:
let community: CommunityModel = try await communityRepository.loadDetails(for: id.contentId)
recentSearches.append(AnyContentModel(community))
newSearches.append(AnyContentModel(community))
case .user:
let user = try await personRepository.loadDetails(for: id.contentId)
recentSearches.append(AnyContentModel(user))
newSearches.append(AnyContentModel(user))
}
}

recentSearches = newSearches
}
}

Expand Down

0 comments on commit 46339b0

Please sign in to comment.