Skip to content

Commit 6c3b20e

Browse files
Thibautihadeed
Thibaut
authored andcommitted
fix(provider): remove platform.ready (#96)
* remove the platform.ready for the Observable, faster loading and better behavior in bad network area * remove the platform.ready for the Observable, faster loading and better behavior in bad network area
1 parent 4ea0375 commit 6c3b20e

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/providers/image-loader.ts

+18-20
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,23 @@ export class ImageLoader {
8080
private fileTransfer: FileTransfer,
8181
private platform: Platform
8282
) {
83-
platform.ready().then(() => {
84-
if (!platform.is('cordova')) {
85-
// we are running on a browser, or using livereload
86-
// plugin will not function in this case
87-
this.isInit = true;
88-
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
89-
} else {
90-
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
91-
if (this.nativeAvailable) {
92-
this.initCache();
93-
} else {
94-
// we are running on a browser, or using livereload
95-
// plugin will not function in this case
96-
this.isInit = true;
97-
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
98-
}
99-
})
100-
}
101-
});
83+
if (!platform.is('cordova')) {
84+
// we are running on a browser, or using livereload
85+
// plugin will not function in this case
86+
this.isInit = true;
87+
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
88+
} else {
89+
Observable.fromEvent(document, 'deviceready').first().subscribe(res => {
90+
if (this.nativeAvailable) {
91+
this.initCache();
92+
} else {
93+
// we are running on a browser, or using livereload
94+
// plugin will not function in this case
95+
this.isInit = true;
96+
this.throwWarning('You are running on a browser or using livereload, IonicImageLoader will not function, falling back to browser loading.');
97+
}
98+
});
99+
}
102100
}
103101

104102
/**
@@ -357,7 +355,7 @@ export class ImageLoader {
357355
.then(files => Promise.all(files.map(this.addFileToIndex.bind(this))))
358356
.then(() => {
359357
// Sort items by date. Most recent to oldest.
360-
this.cacheIndex = this.cacheIndex.sort((a: IndexItem, b: IndexItem): number => a>b?-1:a<b?1:0);
358+
this.cacheIndex = this.cacheIndex.sort((a: IndexItem, b: IndexItem): number => a > b ? -1 : a < b ? 1 : 0);
361359
this.indexed = true;
362360
return Promise.resolve();
363361
})

0 commit comments

Comments
 (0)