Skip to content

Commit

Permalink
tidied up
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Oct 6, 2023
1 parent 9c63554 commit 887a96a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Mlem/Models/Trackers/RecentSearchesTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
5 changes: 2 additions & 3 deletions Mlem/Repositories/PersonRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions Mlem/Views/Tabs/Profile/User View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 887a96a

Please sign in to comment.