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 {
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;
});
},