Skip to content
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

Merged
merged 7 commits into from
Jun 29, 2018
Merged

fix(livereload): Images not loading #161

merged 7 commits into from
Jun 29, 2018

Conversation

eduardoRoth
Copy link
Member

Detects if you're running with livereload over an emulator or device, if so then ignores cached image (not reachable) and loads from URL.

Copy link
Member

@ihadeed ihadeed left a 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.

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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 time getCachedImagePath is called.

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){
Copy link
Member

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

@eduardoRoth
Copy link
Member Author

Thanks @ihadeed , I've updated the pull following your comments.

@ihadeed ihadeed merged commit ead3918 into zyra:master Jun 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants