diff --git a/Sources/swiftarr/Controllers/ForumController.swift b/Sources/swiftarr/Controllers/ForumController.swift index 1e9f4ac2b..5a2b2f903 100644 --- a/Sources/swiftarr/Controllers/ForumController.swift +++ b/Sources/swiftarr/Controllers/ForumController.swift @@ -851,19 +851,9 @@ struct ForumController: APIRouteCollection { try await markNotificationViewed(user: cacheUser, type: .forumMention(0), on: req) } } - let postData = try await buildPostData( - postFilteredPosts, - userID: cacheUser.userID, - on: req, - mutewords: cacheUser.mutewords - ) - return try await PostSearchData( - queryString: req.url.query ?? "", - totalPosts: totalPostsFound, - start: start, - limit: limit, - posts: postData - ) + let postData = try await buildPostData(postFilteredPosts, userID: cacheUser.userID, on: req, mutewords: cacheUser.mutewords) + return try await PostSearchData(queryString: req.url.query ?? "", posts: postData, + paginator: Paginator(total: totalPostsFound, start: start, limit: limit)) } // MARK: POST and DELETE actions diff --git a/Sources/swiftarr/Controllers/Structs/ControllerStructs.swift b/Sources/swiftarr/Controllers/Structs/ControllerStructs.swift index 0df8864eb..ee0d622b8 100644 --- a/Sources/swiftarr/Controllers/Structs/ControllerStructs.swift +++ b/Sources/swiftarr/Controllers/Structs/ControllerStructs.swift @@ -427,7 +427,7 @@ extension FezContentData: RCFValidatable { /// /// public struct FezListData: Content { - /// Pagination into the results set.. + /// Pagination into the results set. var paginator: Paginator ///The fezzes in the result set. var fezzes: [FezData] @@ -1315,15 +1315,11 @@ extension PostData { public struct PostSearchData: Content { /// The search query used to create these results. var queryString: String - /// The total number of posts in the result set. The actual # of results returned may be fewer than this, even if we return 'complete' results. This is due to additional filtering that - /// is done after the database query. See notes on `ContentFilterable.filterForMention(of:)` - var totalPosts: Int - /// The index into totalPosts of the first post in the `posts` array. 0 is the index of the first result. This number is usually a multiple of `limit` and indicates the page of results. - var start: Int - /// The number of posts the server attempted to gather. posts.count may be less than this number if posts were filtered out by post-query filtering, or if start + limit > totalPosts. - var limit: Int /// The posts in the forum. var posts: [PostData] + /// Pagination into the results set. Because `/forum/post/search` filters the result set after the db query, `posts.count` could be less than `paginator.limit` + /// even if we're not at the end of the results. To get the next 'page' of results, be sure to add `limit` to `start`; don't add`posts.count`. + var paginator: Paginator } /// Used to return a `ForumPost`'s data with full user `LikeType` info. diff --git a/Sources/swiftarr/Resources/Views/Forums/forum.html b/Sources/swiftarr/Resources/Views/Forums/forum.html index d3502c18a..73aa04d53 100644 --- a/Sources/swiftarr/Resources/Views/Forums/forum.html +++ b/Sources/swiftarr/Resources/Views/Forums/forum.html @@ -428,7 +428,7 @@