From: Jérôme Benoit Date: Fri, 22 Nov 2024 15:40:25 +0000 (+0100) Subject: fix: ensure local storage is cleaned at CS deletion X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=122e014f0d4d9b9a81b6113de3d280745747670d;p=e-mobility-charging-stations-simulator.git fix: ensure local storage is cleaned at CS deletion Signed-off-by: Jérôme Benoit --- 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()