From bacd2605477e2daa37dbc2b3aa0a73f4445208ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 4 Jun 2021 16:22:15 +0200 Subject: [PATCH] Prevents error message from being displayed twice in the same dialog --- front/src/Stores/ErrorStore.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/front/src/Stores/ErrorStore.ts b/front/src/Stores/ErrorStore.ts index 9647c370..2f1e3e40 100644 --- a/front/src/Stores/ErrorStore.ts +++ b/front/src/Stores/ErrorStore.ts @@ -9,14 +9,18 @@ function createErrorStore() { return { subscribe, addErrorMessage: (e: string|Error): void => { - update((messages) => { + update((messages: string[]) => { let message: string; if (e instanceof Error) { message = e.message; } else { message = e; } - messages.push(message); + + if (!messages.includes(message)) { + messages.push(message); + } + return messages; }); },