Skip to content

Instantly share code, notes, and snippets.

@frosty

frosty/foo.diff

Created Jun 12, 2018
Embed
What would you like to do?
diff --git a/WordPress/Classes/Services/MediaService.m b/WordPress/Classes/Services/MediaService.m
index 14db01070a..3a16b3c4d0 100644
--- a/WordPress/Classes/Services/MediaService.m
+++ b/WordPress/Classes/Services/MediaService.m
@@ -566,14 +566,12 @@ - (void)syncMediaLibraryForBlog:(Blog *)blog
{
id<MediaServiceRemote> remote = [self remoteForBlog:blog];
NSManagedObjectID *blogObjectID = [blog objectID];
- [self.managedObjectContext performBlock:^{
- Blog *blogInContext = (Blog *)[self.managedObjectContext objectWithID:blogObjectID];
- NSSet *originalLocalMedia = blogInContext.media;
- [remote getMediaLibraryWithSuccess:^(NSArray *media) {
- [self.managedObjectContext performBlock:^{
- [self mergeMedia:media forBlog:blogInContext baseMedia:originalLocalMedia completionHandler:success];
- }];
- }
+ Blog *blogInContext = (Blog *)[self.managedObjectContext objectWithID:blogObjectID];
+ [remote getMediaLibraryWithSuccess:^(NSArray *media) {
+ [self.managedObjectContext performBlock:^{
+ [self mergeMedia:media forBlog:blogInContext completionHandler:success];
+ }];
+ }
failure:^(NSError *error) {
if (failure) {
[self.managedObjectContext performBlock:^{
@@ -581,7 +579,6 @@ - (void)syncMediaLibraryForBlog:(Blog *)blog
}];
}
}];
- }];
}
- (NSInteger)getMediaLibraryCountForBlog:(Blog *)blog
@@ -739,9 +736,10 @@ - (NSPredicate *)predicateForMediaTypes:(NSSet *)mediaTypes blog:(Blog *)blog
- (void)mergeMedia:(NSArray *)media
forBlog:(Blog *)blog
- baseMedia:(NSSet *)originalBlogMedia
completionHandler:(void (^)(void))completion
{
+ NSSet *originalBlogMedia = [blog.media copy];
+
NSParameterAssert(blog);
NSParameterAssert(media);
NSMutableSet *mediaToKeep = [NSMutableSet set];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.