Skip to content

Commit

Permalink
Merge pull request #20256 from wordpress-mobile/remove-context-from-m…
Browse files Browse the repository at this point in the history
…edia-service

Remove two unused functions from `MediaService`
  • Loading branch information
crazytonyli authored Mar 7, 2023
2 parents ea6b32e + e8ab26c commit f5c8424
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
26 changes: 0 additions & 26 deletions WordPress/Classes/Services/MediaService.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,32 +142,6 @@ typedef NS_ERROR_ENUM(MediaServiceErrorDomain, MediaServiceError) {
success:(nullable void (^)(void))success
failure:(nullable void (^)(NSError * _Nonnull error))failure;

/**
Gets a local thumbnail image file URL for the Media item, or generates one, if available.
@discussion If the media asset is a video a frame of the video is returned.
@param mediaInRandomContext the Media object from where to get the thumbnail.
@param preferredSize the preferred size for the image in points. If set to CGSizeZero the resulting image will not
exceed the maximum dimension of the UIScreen size.
@param completion block that will be invoked when the thumbnail is ready, if available, or an error if something went wrong.
*/
- (void)thumbnailFileURLForMedia:(nonnull Media *)mediaInRandomContext
preferredSize:(CGSize)preferredSize
completion:(nonnull void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion;
/**
Gets a thumbnail image for the Media item, or generates one, if available.
@discussion If the media asset is a video a frame of the video is returned.
@param mediaInRandomContext the Media object from where to get the thumbnail.
@param preferredSize the preferred size for the image in points. If set to CGSizeZero the resulting image will not
exceed the maximum dimension of the UIScreen size.
@param completion block that will be invoked when the thumbnail is ready, if available, or an error if something went wrong.
*/
- (void)thumbnailImageForMedia:(nonnull Media *)mediaInRandomContext
preferredSize:(CGSize)preferredSize
completion:(nonnull void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion;

- (void)getMediaLibraryServerCountForBlog:(nonnull Blog *)blog
forMediaTypes:(nonnull NSSet *)mediaTypes
Expand Down
47 changes: 0 additions & 47 deletions WordPress/Classes/Services/MediaService.m
Original file line number Diff line number Diff line change
Expand Up @@ -676,53 +676,6 @@ - (void)getMediaLibraryServerCountForBlog:(Blog *)blog

#pragma mark - Thumbnails

- (void)thumbnailFileURLForMedia:(Media *)mediaInRandomContext
preferredSize:(CGSize)preferredSize
completion:(void (^)(NSURL * _Nullable, NSError * _Nullable))completion
{
NSManagedObjectID *mediaID = [mediaInRandomContext objectID];
[self.managedObjectContext performBlock:^{
NSError *error;
Media *media = (Media *)[self.managedObjectContext existingObjectWithID:mediaID error:&error];
if (media == nil) {
completion(nil, error);
return;
}
[self.thumbnailService thumbnailURLForMedia:media
preferredSize:preferredSize
onCompletion:^(NSURL *url) {
completion(url, nil);
}
onError:^(NSError *error) {
completion(nil, error);
}];
}];
}

- (void)thumbnailImageForMedia:(nonnull Media *)mediaInRandomContext
preferredSize:(CGSize)preferredSize
completion:(void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion
{
NSManagedObjectID *mediaID = [mediaInRandomContext objectID];
[self.managedObjectContext performBlock:^{
NSError *error;
Media *media = (Media *)[self.managedObjectContext existingObjectWithID:mediaID error:&error];
if (media == nil) {
completion(nil, error);
return;
}
[self.thumbnailService thumbnailURLForMedia:media
preferredSize:preferredSize
onCompletion:^(NSURL *url) {
UIImage *image = [UIImage imageWithContentsOfFile:url.path];
completion(image, nil);
}
onError:^(NSError *error) {
completion(nil, error);
}];
}];
}

- (MediaThumbnailService *)thumbnailService
{
if (!_thumbnailService) {
Expand Down

0 comments on commit f5c8424

Please sign in to comment.