X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fcomponents%2Fservices%2FOpenWeather.vue;h=ba0be96e92e56e421b173b518e7f313ca3551f9e;hb=23990e85090b425e98e563e2e390044d0695c19d;hp=79d5e37d67eb981e1420d487a9fe9c4cd1c480fd;hpb=049610bc9178a57732356801e20488cf669eda5e;p=github%2Fbastienwirtz%2Fhomer.git diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue index 79d5e37..ba0be96 100644 --- a/src/components/services/OpenWeather.vue +++ b/src/components/services/OpenWeather.vue @@ -22,7 +22,7 @@

{{ name }}

- {{ temp | tempSuffix(this.item.units) }} + {{ temperature }}

@@ -50,6 +50,19 @@ export default { conditions: null, error: false, }), + computed: { + temperature: function () { + if (!this.temp) return ""; + + let unit = "K"; + if (this.item.units === "metric") { + unit = "°C"; + } else if (this.item.units === "imperial") { + unit = "°F"; + } + return `${this.temp} ${unit}`; + }, + }, created() { this.fetchWeather(); }, @@ -86,19 +99,6 @@ export default { }); }, }, - filters: { - tempSuffix: function (value, type) { - if (!value) return ""; - - let unit = "K"; - if (type === "metric") { - unit = "°C"; - } else if (type === "imperial") { - unit = "°F"; - } - return `${value} ${unit}`; - }, - }, };