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

View File

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