mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
releasing downloaded image when multiplex image node exits render range
This commit is contained in:
@@ -139,6 +139,13 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
*/
|
||||
- (void)_downloadImageWithIdentifier:(id)imageIdentifier URL:(NSURL *)imageURL completion:(void (^)(UIImage *image, NSError *error))completionBlock;
|
||||
|
||||
/**
|
||||
@abstract Returns a Boolean value indicating whether the downloaded image should be removed when clearing fetched data
|
||||
@discussion Downloaded image data should only be cleared out if a cache is present
|
||||
@return YES if an image cache is available; otherwise, NO.
|
||||
*/
|
||||
- (BOOL)_shouldClearFetchedImageData;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASMultiplexImageNode
|
||||
@@ -173,11 +180,15 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayWillStart
|
||||
- (void)clearFetchedData
|
||||
{
|
||||
[super displayWillStart];
|
||||
|
||||
[self fetchData];
|
||||
[super clearFetchedData];
|
||||
|
||||
if ([self _shouldClearFetchedImageData]) {
|
||||
// setting this to nil makes the node fetch images the next time its display starts
|
||||
_loadedImageIdentifier = nil;
|
||||
self.image = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fetchData
|
||||
@@ -626,4 +637,8 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
|
||||
[self _loadNextImage];
|
||||
}
|
||||
|
||||
- (BOOL)_shouldClearFetchedImageData {
|
||||
return _cache != nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user