Prevents error message from being displayed twice in the same dialog

This commit is contained in:
David Négrier 2021-06-04 16:22:15 +02:00
parent 9f09dc9df2
commit bacd260547

View File

@ -9,14 +9,18 @@ function createErrorStore() {
return { return {
subscribe, subscribe,
addErrorMessage: (e: string|Error): void => { addErrorMessage: (e: string|Error): void => {
update((messages) => { update((messages: string[]) => {
let message: string; let message: string;
if (e instanceof Error) { if (e instanceof Error) {
message = e.message; message = e.message;
} else { } else {
message = e; message = e;
} }
if (!messages.includes(message)) {
messages.push(message); messages.push(message);
}
return messages; return messages;
}); });
}, },