Update content/scheme icons properly

This commit is contained in:
Samuel Elliott 2018-08-06 02:55:08 +01:00
parent c2f8f5cfab
commit 4b4b3c341f
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 42 additions and 6 deletions

View File

@ -46,7 +46,8 @@
props: ['item'],
data() {
return {
iconURL: undefined
iconURL: undefined,
updatingIcon: false
};
},
components: {
@ -68,10 +69,27 @@
} catch (err) {
Logger.err('ContentCard', ['Invalid icon URL', this.item]);
}
},
async refreshIcon() {
if (this.updatingIcon) return;
this.updatingIcon = true;
this.iconURL = await this.getIconURL();
this.updatingIcon = false;
}
},
async created() {
this.iconURL = await this.getIconURL();
watch: {
'item.contentPath'() {
this.refreshIcon();
},
'item.icon'() {
this.refreshIcon();
},
'item.info.icon_type'() {
this.refreshIcon();
}
},
created() {
this.refreshIcon();
}
}
</script>

View File

@ -24,7 +24,8 @@
props: ['scheme', 'is-active'],
data() {
return {
iconURL: undefined
iconURL: undefined,
updatingIcon: false
};
},
methods: {
@ -38,10 +39,27 @@
} catch (err) {
Logger.err('SettingsScheme', ['Invalid icon URL', this.scheme, err]);
}
},
async refreshIcon() {
if (this.updatingIcon) return;
this.updatingIcon = true;
this.iconURL = this.scheme.icon_url || await this.getIconURLFromPath();
this.updatingIcon = false;
}
},
async created() {
this.iconURL = this.scheme.icon_url || await this.getIconURLFromPath();
watch: {
'scheme.path'() {
this.refreshIcon();
},
'scheme.icon_path'() {
this.refreshIcon();
},
'scheme.icon_type'() {
this.refreshIcon();
}
},
created() {
this.refreshIcon();
}
}
</script>