Skip to content

Commit ead3918

Browse files
eduardoRothihadeed
authored andcommitted
fix(livereload): images not loading (#161)
* fix(wkwebview): Images not loading in Ionic WKWebView * fix(livereload): Images not loading When running in an emulator or in a device with the flag --livereload images were not showing. * lint(livereload): Updated for ihadeed comments
1 parent a15309f commit ead3918

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/providers/image-loader.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export class ImageLoader {
7676
private get isIonicWKWebView(): boolean {
7777
return this.isWKWebView && (location.host === 'localhost:8080' || (<any>window).LiveReload);
7878
}
79+
80+
private get isDevServer() : boolean {
81+
return (window['IonicDevServer'] != undefined);
82+
}
7983

8084
constructor(
8185
private config: ImageLoaderConfig,
@@ -464,6 +468,11 @@ export class ImageLoader {
464468
if (!this.isCacheReady) {
465469
return reject();
466470
}
471+
472+
// if we're running with livereload, ignore cache and call the resource from it's URL
473+
if(this.isDevServer){
474+
return reject();
475+
}
467476

468477
// get file name
469478
const fileName = this.createFileName(url);
@@ -496,10 +505,8 @@ export class ImageLoader {
496505
// in this case only the tempDirectory is accessible,
497506
// therefore the file needs to be copied into that directory first!
498507
if (this.isIonicWKWebView) {
499-
500508
// Use Ionic normalizeUrl to generate the right URL for Ionic WKWebView
501509
resolve(normalizeURL(fileEntry.nativeURL));
502-
503510
} else if (this.isWKWebView) {
504511

505512
// check if file already exists in temp directory

0 commit comments

Comments
 (0)