From fa1e702173beb67b1ab3a5c6a8316794b6d8c131 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 9 Jun 2024 19:26:42 -0500 Subject: [PATCH] Add timestamp param to bust cache when refreshing radar images --- src/stores/weather.js | 2 +- src/views/WeatherView.vue | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/stores/weather.js b/src/stores/weather.js index 0eb592e..f02e4a9 100644 --- a/src/stores/weather.js +++ b/src/stores/weather.js @@ -131,7 +131,7 @@ export const useWeatherStore = defineStore('weather', { if (!this.forecast) { - const weather = await this.getWeather(this.coordinates) + const weather = await this.getWeather() const url = weather.properties.forecast const response = await fetch(url) diff --git a/src/views/WeatherView.vue b/src/views/WeatherView.vue index 3dbc9e3..a76eb96 100644 --- a/src/views/WeatherView.vue +++ b/src/views/WeatherView.vue @@ -11,6 +11,7 @@ const weatherStore = useWeatherStore() const coordinates = ref(null) const refreshing = ref(false) +const timestamp = ref(new Date().getTime()) const panelHeadingTitle = computed(() => { @@ -24,6 +25,16 @@ const panelHeadingTitle = computed(() => { }) +const radarLatestURL = computed(() => { + return `${weatherStore.radarLatestURL}?t=${timestamp.value}` +}) + + +const radarLoopURL = computed(() => { + return `${weatherStore.radarLoopURL}?t=${timestamp.value}` +}) + + onActivated(() => { if (!weatherStore.coordinates) { @@ -56,6 +67,7 @@ async function fetchWeather() { async function refreshWeather() { refreshing.value = true weatherStore.clearWeather(true) + timestamp.value = new Date().getTime() await fetchWeather() refreshing.value = false } @@ -163,10 +175,10 @@ function showHourly(period) {
- +
- +