From a0af89cd2621efd119f79647a030a7f4853bb9f6 Mon Sep 17 00:00:00 2001 From: Hepatica Date: Sat, 27 Jan 2024 19:49:02 +0100 Subject: [PATCH] Add time check for message sending --- luckydiamond/src/components/ChatComponent.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/luckydiamond/src/components/ChatComponent.vue b/luckydiamond/src/components/ChatComponent.vue index ab6596c..c0ebe58 100644 --- a/luckydiamond/src/components/ChatComponent.vue +++ b/luckydiamond/src/components/ChatComponent.vue @@ -43,6 +43,7 @@ export default { return { array: [], id: 0, + lastMsgTime: null, }; }, methods: { @@ -53,8 +54,13 @@ export default { }); }, ClaimDatamsg(msg) { - SendMessageToChat(msg[0]); - + const now = Date.now(); + if (!this.lastMsgTime || now - this.lastMsgTime >= 2000) { + SendMessageToChat(msg[0]); + this.lastMsgTime = now; + } else { + alert("Вы не можете отправлять сообщения чаще, чем раз в 2 секунды."); + } // if(this.array.length > 7) { // this.array.shift() // }