diff --git a/Mlem/Models/Trackers/RecentSearchesTracker.swift b/Mlem/Models/Trackers/RecentSearchesTracker.swift index fc4214fd0..26fc495bf 100644 --- a/Mlem/Models/Trackers/RecentSearchesTracker.swift +++ b/Mlem/Models/Trackers/RecentSearchesTracker.swift @@ -34,8 +34,10 @@ class RecentSearchesTracker: ObservableObject { let community: CommunityModel = try await communityRepository.loadDetails(for: id.contentId) newSearches.append(AnyContentModel(community)) case .user: - let user = try await personRepository.loadDetails(for: id.contentId) + let user = try await personRepository.loadUser(for: id.contentId) newSearches.append(AnyContentModel(user)) + case .comment: + break } } diff --git a/Mlem/Repositories/PersonRepository.swift b/Mlem/Repositories/PersonRepository.swift index ed3dabf43..c773a0538 100644 --- a/Mlem/Repositories/PersonRepository.swift +++ b/Mlem/Repositories/PersonRepository.swift @@ -29,11 +29,10 @@ class PersonRepository { return users } - // TODO: rename to loadUser /// Gets the UserModel for a given user /// - Parameter id: id of the user to get /// - Returns: UserModel for the given user - func loadDetails(for id: Int) async throws -> UserModel { + func loadUser(for id: Int) async throws -> UserModel { let response = try await apiClient.getPersonDetails(for: id, limit: 1, savedOnly: false) return UserModel(from: response.personView) } @@ -44,7 +43,7 @@ class PersonRepository { /// - limit: max number of content items to fetch /// - savedOnly: if present, whether to fetch saved items; calling user must be the requested user /// - Returns: GetPersonDetailsResponse for the given user - func getUserDetails(for id: Int, limit: Int, savedOnly: Bool = false) async throws -> GetPersonDetailsResponse { + func loadUserDetails(for id: Int, limit: Int, savedOnly: Bool = false) async throws -> GetPersonDetailsResponse { try await apiClient.getPersonDetails(for: id, limit: limit, savedOnly: savedOnly) } diff --git a/Mlem/Views/Tabs/Profile/User View.swift b/Mlem/Views/Tabs/Profile/User View.swift index 5b2ab843d..f6c725bba 100644 --- a/Mlem/Views/Tabs/Profile/User View.swift +++ b/Mlem/Views/Tabs/Profile/User View.swift @@ -201,10 +201,10 @@ struct UserView: View { // swiftlint:disable function_body_length private func tryReloadUser() async { do { - let authoredContent = try await personRepository.getUserDetails(for: userID, limit: internetSpeed.pageSize) + let authoredContent = try await personRepository.loadUserDetails(for: userID, limit: internetSpeed.pageSize) var savedContentData: GetPersonDetailsResponse? if isShowingOwnProfile() { - savedContentData = try await personRepository.getUserDetails( + savedContentData = try await personRepository.loadUserDetails( for: userID, limit: internetSpeed.pageSize, savedOnly: true