Skip to content

Commit 1a29c92

Browse files
committed
iOS fixes
1 parent 114d33d commit 1a29c92

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

ios/FirebaseUIImageView.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
#import "UIImageView+FirebaseStorage.h"
1313

1414
@implementation FirebaseImageView
15+
{
16+
BOOL _needsReload;
17+
}
1518

1619
- (void)setPath:(NSString *)path
1720
{
1821
_path = path;
1922

20-
[self reloadImage];
23+
_needsReload = YES;
2124
}
2225

2326
-(void)setTimestamp:(NSNumber*)timestamp
2427
{
2528
_timestamp = timestamp;
26-
[self reloadImage];
29+
30+
_needsReload = YES;
2731
}
2832

2933
- (void)setResizeMode:(RCTResizeMode)resizeMode
@@ -43,8 +47,16 @@ - (void)setResizeMode:(RCTResizeMode)resizeMode
4347
}
4448
}
4549

50+
- (void)didSetProps:(NSArray<NSString *> *)changedProps
51+
{
52+
if (_needsReload) {
53+
[self reloadImage];
54+
}
55+
}
56+
4657
-(void)reloadImage
4758
{
59+
_needsReload = NO;
4860
// Reference to an image file in Firebase Storage
4961
FIRStorageReference *reference = [[FIRStorage storage] referenceWithPath:_path];
5062

ios/UIImageView+FirebaseStorage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616

1717
@import UIKit;
18-
18+
#import <UIKit/UIKit.h>
1919
#import <FirebaseStorage/FirebaseStorage.h>
2020
#import <SDWebImage/UIImageView+WebCache.h>
2121
#import <SDWebImage/UIImage+MultiFormat.h>

ios/UIImageView+FirebaseStorage.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ - (FIRStorageDownloadTask *)sd_setImageWithStorageReference:(FIRStorageReference
117117
self.image = placeholder;
118118

119119
// Query cache for image before trying to download
120-
NSString *key = [storageRef.fullPath stringByAppendingString:customKey];
120+
NSString *key = nil;
121+
if (customKey != nil) {
122+
key = [storageRef.fullPath stringByAppendingString:customKey];
123+
} else {
124+
key = storageRef.fullPath;
125+
}
121126
UIImage *cached = nil;
122127

123128
cached = [cache imageFromMemoryCacheForKey:key];
@@ -148,7 +153,7 @@ - (FIRStorageDownloadTask *)sd_setImageWithStorageReference:(FIRStorageReference
148153
self.image = image;
149154

150155
// Cache downloaded image
151-
[cache storeImage:image forKey:storageRef.fullPath completion:nil];
156+
[cache storeImage:image forKey:key completion:nil];
152157

153158
if (completion != nil) {
154159
completion(image, nil, SDImageCacheTypeNone, storageRef);

0 commit comments

Comments
 (0)