From 15135978cfe4d75dfa6c85fff5ad3b472e813e36 Mon Sep 17 00:00:00 2001 From: carrot <68383195+AnnikaV9@users.noreply.github.com> Date: Thu, 23 Nov 2023 18:07:24 +0800 Subject: [PATCH] Mark message for deletion on next cleanup --- commands/core/chat.js | 3 ++- commands/core/updateMessage.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/core/chat.js b/commands/core/chat.js index 8c4cca1..5ba3dee 100644 --- a/commands/core/chat.js +++ b/commands/core/chat.js @@ -40,7 +40,7 @@ export function cleanActiveMessages() { const now = Date.now(); for (let i = 0; i < ACTIVE_MESSAGES.length; i++) { const message = ACTIVE_MESSAGES[i]; - if (now - message.sent > ACTIVE_TIMEOUT) { + if (now - message.sent > ACTIVE_TIMEOUT || message.toDelete) { ACTIVE_MESSAGES.splice(i, 1); i--; } @@ -62,6 +62,7 @@ export function addActiveMessage(customId, userid) { customId, userid, sent: Date.now(), + toDelete: false, }); } diff --git a/commands/core/updateMessage.js b/commands/core/updateMessage.js index af1a6f1..880d96c 100644 --- a/commands/core/updateMessage.js +++ b/commands/core/updateMessage.js @@ -48,6 +48,9 @@ export async function run({ core, server, socket, payload }) { if (msg.userid === socket.userid && msg.customId === customId) { message = ACTIVE_MESSAGES[i]; + if (mode === 'complete') { + ACTIVE_MESSAGES[i].toDelete = true; + } break; } }