Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized search view rendering #695

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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