From b302bfd1caa485126b4b11b35002ec123bb09627 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 2 May 2026 23:08:50 +0200 Subject: [PATCH] refactor(webui): remove redundant optimistic fetch from modern skin Rely solely on server push (ServerNotification.REFRESH) for data refresh after user actions, eliminating the duplicate getChargingStations() call that was triggered via the need-refresh event chain. --- ui/web/src/shared/composables/useAsyncAction.ts | 2 +- ui/web/src/skins/modern/ModernLayout.vue | 3 +-- ui/web/src/skins/modern/components/ConnectorRow.vue | 2 -- ui/web/src/skins/modern/components/StationCard.vue | 4 +--- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ui/web/src/shared/composables/useAsyncAction.ts b/ui/web/src/shared/composables/useAsyncAction.ts index 12398a49..04ca14cc 100644 --- a/ui/web/src/shared/composables/useAsyncAction.ts +++ b/ui/web/src/shared/composables/useAsyncAction.ts @@ -11,7 +11,7 @@ import { useToast } from 'vue-toast-notification' * Encapsulates the pending-key guard, toast feedback, and error logging pattern * shared across layout composables. * @param initialPending - Object defining the pending keys (e.g. `{ connection: false, startStop: false }`) - * @param onRefresh - Called after each successful action (e.g. `() => emit('need-refresh')`) + * @param onRefresh - Called after each successful action to signal state has changed * @returns `{ pending, run }` — reactive pending map and action executor */ export function useAsyncAction> ( diff --git a/ui/web/src/skins/modern/ModernLayout.vue b/ui/web/src/skins/modern/ModernLayout.vue index e9f2a0c7..949ac6c9 100644 --- a/ui/web/src/skins/modern/ModernLayout.vue +++ b/ui/web/src/skins/modern/ModernLayout.vue @@ -31,7 +31,6 @@ v-for="station in $chargingStations" :key="station.stationInfo.hashId" :charging-station="station" - @need-refresh="getChargingStations" @open-authorize="openAuthorizeDialog" @open-set-url="openSetUrlDialog" @open-start-tx="openStartTxDialog" @@ -125,7 +124,7 @@ const StartTransactionDialog = defineAsyncDialog( const $chargingStations = useChargingStations() const layoutData = useLayoutData() -const { getChargingStations, simulatorState, uiServerConfigurations } = layoutData +const { simulatorState, uiServerConfigurations } = layoutData const uiServerIndex = ref(getFromLocalStorage(UI_SERVER_CONFIGURATION_INDEX_KEY, 0)) diff --git a/ui/web/src/skins/modern/components/ConnectorRow.vue b/ui/web/src/skins/modern/components/ConnectorRow.vue index e7518336..f24fd1bc 100644 --- a/ui/web/src/skins/modern/components/ConnectorRow.vue +++ b/ui/web/src/skins/modern/components/ConnectorRow.vue @@ -176,7 +176,6 @@ const props = defineProps<{ }>() const emit = defineEmits<{ - 'need-refresh': [] 'open-start-tx': [ data: { chargingStationId: string @@ -198,7 +197,6 @@ const { } = useConnectorActions({ connectorId: computed(() => props.connectorId), hashId: computed(() => props.hashId), - onRefresh: () => emit('need-refresh'), }) const identifier = computed(() => diff --git a/ui/web/src/skins/modern/components/StationCard.vue b/ui/web/src/skins/modern/components/StationCard.vue index d874cf39..3fd17d98 100644 --- a/ui/web/src/skins/modern/components/StationCard.vue +++ b/ui/web/src/skins/modern/components/StationCard.vue @@ -111,7 +111,6 @@ :evse-id="entry.evseId" :hash-id="chargingStation.stationInfo.hashId" :ocpp-version="chargingStation.stationInfo.ocppVersion" - @need-refresh="$emit('need-refresh')" @open-start-tx="data => $emit('open-start-tx', data)" /> @@ -187,7 +186,6 @@ const props = defineProps<{ }>() const emit = defineEmits<{ - 'need-refresh': [] 'open-authorize': [data: { chargingStationId: string; hashId: string; ocppVersion?: OCPPVersion }] 'open-set-url': [data: { chargingStationId: string; hashId: string }] 'open-start-tx': [ @@ -204,7 +202,7 @@ const emit = defineEmits<{ const confirmingDelete = ref(false) const { closeConnection, deleteStation, openConnection, pending, startStation, stopStation } = - useStationActions({ onRefresh: () => emit('need-refresh') }) + useStationActions() const wsOpen = computed(() => props.chargingStation.wsState === WebSocketReadyState.OPEN) -- 2.43.0