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(); const now = Date.now();
for (let i = 0; i < ACTIVE_MESSAGES.length; i++) { for (let i = 0; i < ACTIVE_MESSAGES.length; i++) {
const message = ACTIVE_MESSAGES[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); ACTIVE_MESSAGES.splice(i, 1);
i--; i--;
} }
@ -62,6 +62,7 @@ export function addActiveMessage(customId, userid) {
customId, customId,
userid, userid,
sent: Date.now(), 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) { if (msg.userid === socket.userid && msg.customId === customId) {
message = ACTIVE_MESSAGES[i]; message = ACTIVE_MESSAGES[i];
if (mode === 'complete') {
ACTIVE_MESSAGES[i].toDelete = true;
}
break; break;
} }
} }