From 122e014f0d4d9b9a81b6113de3d280745747670d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 22 Nov 2024 16:40:25 +0100 Subject: [PATCH] fix: ensure local storage is cleaned at CS deletion MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ui/web/src/components/charging-stations/CSData.vue | 7 ++++++- ui/web/src/views/ChargingStationsView.vue | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index c01302b9..d735ca32 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -131,7 +131,7 @@ import type { ChargingStationData, ConnectorStatus, Status } from '@/types' import Button from '@/components/buttons/Button.vue' import ToggleButton from '@/components/buttons/ToggleButton.vue' import CSConnector from '@/components/charging-stations/CSConnector.vue' -import { useUIClient } from '@/composables' +import { deleteFromLocalStorage, getLocalStorage, useUIClient } from '@/composables' import { useToast } from 'vue-toast-notification' const props = defineProps<{ @@ -229,6 +229,11 @@ const deleteChargingStation = (): void => { uiClient .deleteChargingStation(props.chargingStation.stationInfo.hashId) .then(() => { + for (const key in getLocalStorage()) { + if (key.includes(props.chargingStation.stationInfo.hashId)) { + deleteFromLocalStorage(key) + } + } return $toast.success('Charging station successfully deleted') }) .catch((error: Error) => { diff --git a/ui/web/src/views/ChargingStationsView.vue b/ui/web/src/views/ChargingStationsView.vue index b532ba25..603cfdac 100644 --- a/ui/web/src/views/ChargingStationsView.vue +++ b/ui/web/src/views/ChargingStationsView.vue @@ -24,6 +24,7 @@ () => { setToLocalStorage('uiServerConfigurationIndex', state.uiServerIndex) clearToggleButtons() + refresh() $route.name !== 'charging-stations' && $router.push({ name: 'charging-stations' }) }, @@ -165,14 +166,17 @@ const state = ref<{ uiServerIndex: getFromLocalStorage('uiServerConfigurationIndex', 0), }) +const refresh = (): void => { + state.value.renderChargingStations = randomUUID() + state.value.renderAddChargingStations = randomUUID() +} + const clearToggleButtons = (): void => { for (const key in getLocalStorage()) { if (key.includes('toggle-button')) { deleteFromLocalStorage(key) } } - state.value.renderChargingStations = randomUUID() - state.value.renderAddChargingStations = randomUUID() } const app = getCurrentInstance() -- 2.34.1