From 0622f2a11e32fc0bc12b4a821272c3f94cf6bf5d Mon Sep 17 00:00:00 2001 From: Elijah Windsor Date: Thu, 7 Dec 2017 09:08:25 -0500 Subject: [PATCH 1/3] Ignoring photos in cache that aren't fully downloaded yet --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index fe3ff10..0cfb567 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -116,7 +116,7 @@ export class ImageCache { private get(uri: string) { const cache = this.cache[uri]; - if (cache.path) { + if (cache.path && cache.downloading == false) { // We check here if IOS didn't delete the cache content RNFetchBlob.fs.exists(cache.path).then((exists: boolean) => { if (exists) { From fa5cb0fe9d2922d517a07c2b7bf0b7512bbccf0f Mon Sep 17 00:00:00 2001 From: Elijah Windsor Date: Wed, 13 Dec 2017 09:42:54 -0500 Subject: [PATCH 2/3] Ensuring valid extension -- if not, use .jpg --- src/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 0cfb567..dc7e41e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -26,7 +26,11 @@ export class ImageCache { private getPath(uri: string, immutable?: boolean): string { let path = uri.substring(uri.lastIndexOf("/")); path = path.indexOf("?") === -1 ? path : path.substring(path.lastIndexOf("."), path.indexOf("?")); - const ext = path.indexOf(".") === -1 ? ".jpg" : path.substring(path.indexOf(".")); + let ext = path.indexOf(".") === -1 ? ".jpg" : path.substring(path.indexOf(".")); + if(['.jpg','.gif','.jpeg','.png'].indexOf(ext.toLowerCase()) == -1) { // ensure it's a valid extension + ext = '.jpg' + } + if (immutable === true) { return BASE_DIR + "/" + SHA1(uri) + ext; } else { @@ -225,6 +229,7 @@ export class CachedImage extends BaseCachedImage { if (React.Children.count(this.props.children) > 0) { console.warn("Using with children is deprecated, use instead."); } + console.log('~~~~~', props) return {this.props.children}; } } From 13ff32b58fef9501c1a527daf13a8fc64cd0bfbb Mon Sep 17 00:00:00 2001 From: Elijah Windsor Date: Wed, 13 Dec 2017 12:01:08 -0500 Subject: [PATCH 3/3] Removed comments --- src/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index dc7e41e..3ba3251 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -229,7 +229,6 @@ export class CachedImage extends BaseCachedImage { if (React.Children.count(this.props.children) > 0) { console.warn("Using with children is deprecated, use instead."); } - console.log('~~~~~', props) return {this.props.children}; } }