From 63c9cd498081338bfad93506cd9fb1b1ca607f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Cal=C3=A5s?= Date: Mon, 4 Mar 2024 12:46:22 +0100 Subject: [PATCH] Added devtools debugging, fixed history to reorder when selecting a city --- weather-forecast/src/components/WeatherInfo.vue | 14 +++++--------- weather-forecast/vue.config.js | 1 + 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/weather-forecast/src/components/WeatherInfo.vue b/weather-forecast/src/components/WeatherInfo.vue index 90f962f..0888484 100644 --- a/weather-forecast/src/components/WeatherInfo.vue +++ b/weather-forecast/src/components/WeatherInfo.vue @@ -67,8 +67,6 @@ export default { city: this.resultCity, temperature: this.resultTemp, weather: this.resultWeather, - latitude: this.cityLatitude, - longitude: this.cityLongitude }) this.submitted = true @@ -79,18 +77,16 @@ export default { if (!cityExists) { this.searchHistory.unshift(search); // Lägger till element i början av array this.searchHistory = this.searchHistory.slice(0, 3); // Begränsar antalet element i array till 3, som visas på skärmen. - localStorage.setItem('searchHistory', JSON.stringify(this.searchHistory)); //Lägger till arrayen i LocalStorage. } else { - return; + let index = this.searchHistory.findIndex(city => city.city === search.city); + this.searchHistory.unshift(this.searchHistory.splice(index, 1)[0]) } + localStorage.setItem('searchHistory', JSON.stringify(this.searchHistory)); //Lägger till arrayen i LocalStorage. }, ShowCityBoxClick(search) { - this.resultCity = search.city; - this.resultTemp = search.temperature; - this.resultWeather = search.weather; - this.cityLatitude = search.latitude; - this.cityLongitude = search.longitude; + this.city = search.city; + this.FetchWeather(); this.submitted = true; }, diff --git a/weather-forecast/vue.config.js b/weather-forecast/vue.config.js index 912f250..1eb7404 100644 --- a/weather-forecast/vue.config.js +++ b/weather-forecast/vue.config.js @@ -3,6 +3,7 @@ const webpack = require('webpack'); module.exports = defineConfig({ configureWebpack: { + devtool: 'source-map', plugins: [ new webpack.DefinePlugin({ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',