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:
parent
051d488c21
commit
15135978cf
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user