Skip to content

Commit fab54fb

Browse files
authored
Merge branch 'wpios-edition' into add-search-param-in-theme-service-remote
2 parents 5ec2833 + 554d3ef commit fab54fb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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)