Skip to content

Commit

Permalink
fix(): add platform is cordova check for ionic serve / browser usage (#…
Browse files Browse the repository at this point in the history
…78)

* add platform is cordova check for ionic serve / browser usage

* fix init to isInit
  • Loading branch information
dmastag authored and ihadeed committed Jul 15, 2017
1 parent d797f57 commit a42d1d8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/providers/image-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,25 @@ export class ImageLoader {
private fileTransfer: FileTransfer,
private platform: Platform
) {
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
if (this.nativeAvailable) {
this.initCache();
} else {
platform.ready().then(() => {
if (!platform.is('cordova')) {
// we are running on a browser, or using livereload
// plugin will not function in this case
this.isInit = true;
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
} else {
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
if (this.nativeAvailable) {
this.initCache();
} else {
// we are running on a browser, or using livereload
// plugin will not function in this case
this.isInit = true;
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
}
})
}
})
});
}

/**
Expand Down

0 comments on commit a42d1d8

Please sign in to comment.