From 5597ed0dad451530d4e5c42b61bfb5aba4b1566a Mon Sep 17 00:00:00 2001 From: Shingo YAMADE Date: Thu, 27 Jun 2019 18:39:21 -0700 Subject: [PATCH] fix: Fix setting props order issue for iOS. (#303) fix #304 --- ios/FastImage/FFFastImageView.m | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ios/FastImage/FFFastImageView.m b/ios/FastImage/FFFastImageView.m index 892e33c1a..684f1d59e 100644 --- a/ios/FastImage/FFFastImageView.m +++ b/ios/FastImage/FFFastImageView.m @@ -1,11 +1,12 @@ #import "FFFastImageView.h" - @interface FFFastImageView() @property (nonatomic, assign) BOOL hasSentOnLoadStart; @property (nonatomic, assign) BOOL hasCompleted; @property (nonatomic, assign) BOOL hasErrored; +// Whether the latest change of props requires the image to be reloaded +@property (nonatomic, assign) BOOL needsReload; @property (nonatomic, strong) NSDictionary* onLoadEvent; @@ -97,7 +98,23 @@ - (void)sendOnLoad:(UIImage *)image { - (void)setSource:(FFFastImageSource *)source { if (_source != source) { _source = source; - + needsReload = YES; + } +} + +- (void)didSetProps:(NSArray *)changedProps +{ + if (needsReload) { + [self reloadImage]; + } +} + +- (void)reloadImage +{ + needsReload = NO; + + if (_source) { + // Load base64 images. NSString* url = [_source.url absoluteString]; if (url && [url hasPrefix:@"data:image"]) {