From 04af86e3a947bad28a012df9146bfb5621c2603c Mon Sep 17 00:00:00 2001 From: Leo Choi Date: Wed, 19 Jul 2017 13:18:09 +0800 Subject: [PATCH 1/2] Attempt to fix #80 --- src/providers/image-loader.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/providers/image-loader.ts b/src/providers/image-loader.ts index 7c6cafe..8eedca5 100644 --- a/src/providers/image-loader.ts +++ b/src/providers/image-loader.ts @@ -7,6 +7,8 @@ import * as _ from 'lodash'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/first'; +declare var LiveReload: any; + interface IndexItem { name: string; modificationTime: Date; @@ -67,11 +69,28 @@ export class ImageLoader { } private get isWKWebView(): boolean { - return this.platform.is('ios') && (window).webkit; + if (this.platform.is('ios') && (window).webkit && (window).webkit.messageHandlers) { + return true; + } + + return false; } private get isIonicWKWebView(): boolean { - return this.isWKWebView && location.host === 'localhost:8080'; + if (this.isWKWebView) { + + // Native + if (location.host === 'localhost:8080') { + return true; + } + + // Live reload + if (LiveReload) { + return true; + } + } + + return false; } constructor( @@ -241,7 +260,7 @@ export class ImageLoader { // take the first item from queue const currentItem: QueueItem = this.queue.splice(0, 1)[0]; - + // create FileTransferObject instance if needed // we would only reach here if current jobs < concurrency limit // so, there's no need to check anything other than the length of From 8312c675ea5cca2087ad0817a1fc3f63ce5eb498 Mon Sep 17 00:00:00 2001 From: Leo Choi Date: Sun, 23 Jul 2017 14:56:37 +0800 Subject: [PATCH 2/2] Simplified isWKWebView and isIonicWKWebView --- src/providers/image-loader.ts | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/providers/image-loader.ts b/src/providers/image-loader.ts index 8eedca5..83792db 100644 --- a/src/providers/image-loader.ts +++ b/src/providers/image-loader.ts @@ -7,8 +7,6 @@ import * as _ from 'lodash'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/first'; -declare var LiveReload: any; - interface IndexItem { name: string; modificationTime: Date; @@ -69,28 +67,11 @@ export class ImageLoader { } private get isWKWebView(): boolean { - if (this.platform.is('ios') && (window).webkit && (window).webkit.messageHandlers) { - return true; - } - - return false; + return this.platform.is('ios') && (window).webkit && (window).webkit.messageHandlers; } private get isIonicWKWebView(): boolean { - if (this.isWKWebView) { - - // Native - if (location.host === 'localhost:8080') { - return true; - } - - // Live reload - if (LiveReload) { - return true; - } - } - - return false; + return this.isWKWebView && (location.host === 'localhost:8080' || (window).LiveReload); } constructor(