Skip to content

Commit

Permalink
fix - missing limit on post tracker refresh (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
mormaer authored Sep 22, 2023
1 parent e298fc5 commit b7d8925
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
14 changes: 10 additions & 4 deletions Mlem/API/APIClient/APIClient+Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import Foundation

extension APIClient {
// swiftlint:disable function_parameter_count
func loadPosts(
communityId: Int?,
page: Int,
sort: PostSortType?,
type: FeedType,
limit: Int? = nil,
savedOnly: Bool? = nil,
communityName: String? = nil
limit: Int?,
savedOnly: Bool?,
communityName: String?
) async throws -> [APIPostView] {
let request = try GetPostsRequest(
session: session,
Expand All @@ -30,6 +31,8 @@ extension APIClient {

return try await perform(request: request).posts
}

// swiftlint:enable function_parameter_count

func markPostAsRead(for postId: Int, read: Bool) async throws -> PostResponse {
let request = try MarkPostReadRequest(session: session, postId: postId, read: read)
Expand Down Expand Up @@ -60,13 +63,14 @@ extension APIClient {
return try await perform(request: request)
}

// swiftlint:disable function_parameter_count
func editPost(
postId: Int,
name: String?,
url: String?,
body: String?,
nsfw: Bool?,
languageId: Int? = nil
languageId: Int?
) async throws -> PostResponse {
let request = try EditPostRequest(
session: session,
Expand All @@ -80,6 +84,8 @@ extension APIClient {

return try await perform(request: request)
}

// swiftlint:enable function_parameter_count

func ratePost(id: Int, score: ScoringOperation) async throws -> APIPostView {
let request = try CreatePostLikeRequest(session: session, postId: id, score: score)
Expand Down
3 changes: 2 additions & 1 deletion Mlem/Models/Trackers/Post Tracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class PostTracker: ObservableObject {
communityId: communityId,
page: page,
sort: sort,
type: feedType
type: feedType,
limit: internetSpeed.pageSize
)

await reset(with: newPosts, filteredWith: filtering)
Expand Down
9 changes: 6 additions & 3 deletions Mlem/Repositories/PostRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PostRepository {
page: Int,
sort: PostSortType?,
type: FeedType,
limit: Int? = nil,
limit: Int,
savedOnly: Bool? = nil,
communityName: String? = nil
) async throws -> [PostModel] {
Expand Down Expand Up @@ -77,20 +77,23 @@ class PostRepository {
/// - url: new post url
/// - body: new post body
/// - nsfw: new post nsfw status
/// - languageId: the language id for the post if available
/// - Returns: PostModel with the new state of the post
func editPost(
postId: Int,
name: String?,
url: String?,
body: String?,
nsfw: Bool?
nsfw: Bool?,
languageId: Int? = nil
) async throws -> PostModel {
let response = try await apiClient.editPost(
postId: postId,
name: name,
url: url,
body: body,
nsfw: nsfw
nsfw: nsfw,
languageId: languageId
)
return PostModel(from: response.postView)
}
Expand Down

0 comments on commit b7d8925

Please sign in to comment.