]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - src/components/services/OpenWeather.vue
Fix lint issues
[github/bastienwirtz/homer.git] / src / components / services / OpenWeather.vue
index 79d5e37d67eb981e1420d487a9fe9c4cd1c480fd..756abf77f2b1656bb6aa3167034490dca78d2b50 100644 (file)
@@ -22,7 +22,7 @@
               <div v-else>
                 <p class="title is-4">{{ name }}</p>
                 <p class="subtitle is-6">
-                  {{ temp | tempSuffix(this.item.units) }}
+                  {{ temperature }}
                 </p>
               </div>
             </div>
@@ -50,6 +50,19 @@ export default {
     conditions: null,
     error: false,
   }),
+  computed: {
+    temperature: function () {
+      if (!this.temp) return "";
+
+      let unit = "K";
+      if (this.item.type === "metric") {
+        unit = "°C";
+      } else if (this.item.type === "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}`;
-    },
-  },
 };
 </script>