fix(ui): ensure the charging stations list re-rendered after UI server
[e-mobility-charging-stations-simulator.git] / ui / web / src / main.ts
index f3c9ef036f6fb46445aa2f06f0c482d632e4e1cc..0e79968462d64a39b87bd39afc86d0b3feaea48a 100644 (file)
@@ -37,20 +37,24 @@ const initializeApp = (app: AppType, config: ConfigurationData) => {
         getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
       ]
     )
-    app.config.globalProperties.$uiClient.registerWSEventListener('open', () => {
-      app.config.globalProperties.$uiClient
-        .listChargingStations()
-        .then((response: ResponsePayload) => {
-          app.config.globalProperties.$chargingStations = response.chargingStations
-        })
-        .catch((error: Error) => {
-          // TODO: add code for UI notifications or other error handling logic
-          console.error('Error at fetching charging stations:', error)
-        })
-        .finally(() => {
-          app.use(router).use(ToastPlugin).mount('#app')
-        })
-    })
+    app.config.globalProperties.$uiClient.registerWSEventListener(
+      'open',
+      () => {
+        app.config.globalProperties.$uiClient
+          .listChargingStations()
+          .then((response: ResponsePayload) => {
+            app.config.globalProperties.$chargingStations = response.chargingStations
+          })
+          .catch((error: Error) => {
+            // TODO: add code for UI notifications or other error handling logic
+            console.error('Error at fetching charging stations:', error)
+          })
+          .finally(() => {
+            app.use(router).use(ToastPlugin).mount('#app')
+          })
+      },
+      { once: true }
+    )
   }
 }