Skip to content

Commit 5c0bf55

Browse files
authored
Load all categories instead of just the first page (#24785)
* Update wordpress-rs * Adopt API changes in wordpress-rs The `raw` property becomes Optional in Automattic/wordpress-rs#863, to handle revision related endpoints. However, it's still returned in the /media?context=edit responses. * Loading all categories instead of just the first page
1 parent e5759b3 commit 5c0bf55

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

Modules/Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let package = Package(
5555
),
5656
.package(url: "https://github.com/zendesk/support_sdk_ios", from: "8.0.3"),
5757
// We can't use wordpress-rs branches nor commits here. Only tags work.
58-
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250813"),
58+
.package(url: "https://github.com/Automattic/wordpress-rs", revision: "alpha-20250901"),
5959
.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.8.0"),
6060
.package(
6161
url: "https://github.com/Automattic/color-studio",

WordPress/Classes/Services/MediaServiceRemoteCoreREST.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private extension RemoteMedia {
144144

145145
self.mediaID = NSNumber(value: media.id)
146146
self.url = URL(string: media.sourceUrl)
147-
self.guid = URL(string: media.guid.raw)
147+
self.guid = media.guid.raw.flatMap(URL.init(string:))
148148
self.date = media.dateGmt
149149
self.postID = media.postId.map { NSNumber(value: $0) }
150150
self.mimeType = media.mimeType

WordPress/Classes/Services/TaxonomyServiceRemoteCoreREST.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ import WordPressAPIInternal
3737
public func getCategoriesWithSuccess(_ success: @escaping ([RemotePostCategory]) -> Void, failure: ((any Error) -> Void)? = nil) {
3838
Task { @MainActor in
3939
do {
40-
let response = try await client.api.categories.listWithEditContext(params: CategoryListParams())
41-
let categories = response.data.map(RemotePostCategory.init(category:))
40+
let sequence = await client.api.categories.sequenceWithEditContext(params: CategoryListParams(perPage: 100))
41+
let categories: [RemotePostCategory] = try await sequence.reduce(into: []) {
42+
let page = $1.map(RemotePostCategory.init(category:))
43+
$0.append(contentsOf: page)
44+
}
4245
success(categories)
4346
} catch {
4447
failure?(error)

0 commit comments

Comments
 (0)