Don't load mdi icons with JS - it doesn't do anything. (#546)

This commit is contained in:
Andrey 2017-11-04 05:36:00 +02:00 committed by Paulus Schoutsen
parent fdf2fa3d3f
commit c3a6495eb1

View File

@ -39,7 +39,7 @@
<login-form <login-form
hass='[[hass]]' hass='[[hass]]'
connection-promise='{{connectionPromise}}' connection-promise='{{connectionPromise}}'
show-loading='[[computeShowLoading(connectionPromise, hass, iconsLoaded)]]'> show-loading='[[computeShowLoading(connectionPromise, hass)]]'>
</login-form> </login-form>
</template> </template>
</template> </template>
@ -72,16 +72,9 @@ class HomeAssistant extends Polymer.Element {
type: Object, type: Object,
value: null, value: null,
}, },
icons: {
type: String,
},
iconsLoaded: {
type: Boolean,
value: false,
},
showMain: { showMain: {
type: Boolean, type: Boolean,
computed: 'computeShowMain(hass, iconsLoaded)', computed: 'computeShowMain(hass)',
}, },
}; };
} }
@ -90,33 +83,16 @@ class HomeAssistant extends Polymer.Element {
super.ready(); super.ready();
this.addEventListener('settheme', e => this.setTheme(e)); this.addEventListener('settheme', e => this.setTheme(e));
this.addEventListener('hass-language-select', e => this.selectLanguage(e)); this.addEventListener('hass-language-select', e => this.selectLanguage(e));
this.loadIcons();
this.loadResources(); this.loadResources();
} }
computeShowMain(hass, iconsLoaded) { computeShowMain(hass) {
return hass && hass.states && hass.config && iconsLoaded; return hass && hass.states && hass.config;
} }
computeShowLoading(connectionPromise, hass, iconsLoaded) { computeShowLoading(connectionPromise, hass) {
// Show loading when connecting or when connected but not all pieces loaded yet // Show loading when connecting or when connected but not all pieces loaded yet
return (connectionPromise != null || return (connectionPromise != null || (hass && (!hass.states || !hass.config)));
(hass && (!hass.states || !hass.config || !iconsLoaded)));
}
loadIcons() {
// If the import fails, we'll try to import again, must be a server glitch
// Since HTML imports only resolve once, in prod mode we import another url.
const success = () => {
this.iconsLoaded = true;
};
Polymer.importHref(
'/static/mdi' + this.icons + '.html',
success,
() => Polymer.importHref('/static/mdi.html', success, success),
true /* true for async */
);
} }
loadResources() { loadResources() {