-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(livereload): Images not loading #161
Conversation
…ebview fix(wkwebview): Images not loading in Ionic WKWebView
When running in an emulator or in a device with the flag --livereload images were not showing.
fix(livereload): Images not loading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Just minor changes.
src/providers/image-loader.ts
Outdated
@@ -414,12 +414,19 @@ export class ImageLoader { | |||
* @returns {Promise<string>} Returns a promise that resolves with the local path if exists, or rejects if doesn't exist | |||
*/ | |||
private getCachedImagePath(url: string): Promise<string> { | |||
// Check if we're running with livereload | |||
let _isDev: boolean = (window['IonicDevServer'] != undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If the
IonicDevServer
variable is defined before the app loads, it makes more sense to make this a global variable (either a variable outside the class, or a private property of the class). This way we don't have to evaluate the expression every timegetCachedImagePath
is called.
src/providers/image-loader.ts
Outdated
return new Promise<string>((resolve, reject) => { | ||
|
||
// make sure cache is ready | ||
if (!this.isCacheReady) { | ||
return reject(); | ||
} | ||
|
||
// if we're running with livereload, ignore cache and call the resource from it's URL | ||
if(!!_isDev){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!
is not required.. since window['IonicDevServer'] != undefined
or typeof window['IonicDevServer'] !== 'undefined'
will always return a boolean
Thanks @ihadeed , I've updated the pull following your comments. |
Detects if you're running with livereload over an emulator or device, if so then ignores cached image (not reachable) and loads from URL.