1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Mark message for deletion on next cleanup

This commit is contained in:
carrot 2023-11-23 18:07:24 +08:00
parent 051d488c21
commit 15135978cf
2 changed files with 5 additions and 1 deletions

View File

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

View File

@ -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;
}
}