Skip to content

Commit 554d3ef

Browse files
authored
Exclude deleted sites from getBlogs (#833)
2 parents ba542ba + baf2f40 commit 554d3ef

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ let package = Package(
1111
targets: [
1212
.binaryTarget(
1313
name: "WordPressKit",
14-
url: "https://github.com/user-attachments/files/19034191/WordPressKit.zip",
15-
checksum: "34f108cba86b5e4334d1c9af79946dbb8b665e270bdd14bc8f7bc0ba7a898583"
14+
url: "https://github.com/user-attachments/files/19315257/WordPressKit.zip",
15+
checksum: "1b4ba5cef01a64e98ffdc02a5c8ac92f550f234222bfb6abf11b4b4df94435bc"
1616
),
1717
]
1818
)

Sources/WordPressKit/Models/RemoteBlog.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import Foundation
5858
/// Blog's total disk quota space used.
5959
public var quotaSpaceUsed: NSNumber?
6060

61+
public var isDeleted: Bool
62+
6163
/// Parses details from a JSON dictionary, as returned by the WordPress.com REST API.
6264
@objc(initWithJSONDictionary:)
6365
public init(jsonDictionary json: NSDictionary) {
@@ -79,6 +81,7 @@ import Foundation
7981
self.planActiveFeatures = (json.array(forKeyPath: "plan.features.active") as? [String]) ?? []
8082
self.quotaSpaceAllowed = json.number(forKeyPath: "quota.space_allowed")
8183
self.quotaSpaceUsed = json.number(forKeyPath: "quota.space_used")
84+
self.isDeleted = json.number(forKey: "is_deleted")?.boolValue == true
8285
}
8386

8487
}

Sources/WordPressKit/Services/AccountServiceRemoteREST.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,14 @@ - (RemoteUser *)remoteUserFromDictionary:(NSDictionary *)dictionary
385385
- (NSArray *)remoteBlogsFromJSONArray:(NSArray *)jsonBlogs
386386
{
387387
NSArray *blogs = jsonBlogs;
388-
return [blogs wpkit_map:^id(NSDictionary *jsonBlog) {
388+
return [[blogs wpkit_map:^id(NSDictionary *jsonBlog) {
389389
return [[RemoteBlog alloc] initWithJSONDictionary:jsonBlog];
390+
}] wpkit_filter:^BOOL(RemoteBlog *blog) {
391+
// Exclude deleted sites from query result, since the app does not handle deleted sites properly.
392+
// I tried to use query arguments `site_visibility=visible` and `site_activity=active`, but neither excludes
393+
// deleted sites.
394+
return !blog.isDeleted;
390395
}];
391-
return blogs;
392396
}
393397

394398
@end

0 commit comments

Comments
 (0)