From 8a79cdecff196bb5579553227f9ead84f1498b35 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Wed, 24 Apr 2024 12:23:32 +0300 Subject: [PATCH] Fixed #5225 - Toast: Race condition on remove --- components/lib/toast/Toast.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/lib/toast/Toast.vue b/components/lib/toast/Toast.vue index fbe64db2b..05f3617d7 100755 --- a/components/lib/toast/Toast.vue +++ b/components/lib/toast/Toast.vue @@ -72,17 +72,12 @@ export default { this.messages = [...this.messages, message]; }, remove(params) { - let index = -1; + const index = this.messages.findIndex((m) => m.id === params.message.id); - for (let i = 0; i < this.messages.length; i++) { - if (this.messages[i] === params.message) { - index = i; - break; - } + if (index !== -1) { + this.messages.splice(index, 1); + this.$emit(params.type, { message: params.message }); } - - this.messages.splice(index, 1); - this.$emit(params.type, { message: params.message }); }, onAdd(message) { if (this.group == message.group) {