From 0dd44372e806bf88eb738effe080e2dade846ff2 Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 9 Feb 2023 21:27:47 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Don=C2=B4t=20overwrite=20s?= =?UTF-8?q?tore.passages=20structure=20during=20its=20update=20by=20the=20?= =?UTF-8?q?addPassage=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/businessData.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/businessData.tsx b/frontend/src/businessData.tsx index 4383022..c2e2388 100644 --- a/frontend/src/businessData.tsx +++ b/frontend/src/businessData.tsx @@ -61,7 +61,20 @@ export function BusinessDataProvider(props: { children: JSX.Element }) { } const addPassages = (passages: Passages): void => { - setStore('passages', passages); + const storePassages = store.passages; + for (const lineId of Object.keys(passages)) { + const newLinePassages = passages[lineId]; + const linePassages = storePassages[lineId]; + if (linePassages === undefined) { + setStore('passages', lineId, newLinePassages); + } + else { + for (const destination of Object.keys(newLinePassages)) { + const newLinePassagesDestination = newLinePassages[destination]; + setStore('passages', lineId, destination, newLinePassagesDestination); + } + } + } } const clearPassages = (): void => {