force user to wait 1 second before sending another message

This commit is contained in:
liamcottle
2025-02-13 16:56:46 +13:00
parent bfebaa8a90
commit c753b03479
4 changed files with 38 additions and 23 deletions

View File

@@ -175,13 +175,8 @@ class Connection {
// send message
const message = await GlobalState.connection.sendTextMessage(publicKey, text);
// mark message as failed after estimated timeout
setTimeout(async () => {
await Database.Message.setMessageFailedByAckCode(message.expectedAckCrc, "timeout");
}, message.estTimeout);
// save to database
await Database.Message.insert({
const databaseMessage = await Database.Message.insert({
status: "sending",
to: publicKey,
from: GlobalState.selfInfo.publicKey,
@@ -195,6 +190,11 @@ class Connection {
error: null,
});
// mark message as failed after estimated timeout
setTimeout(async () => {
await Database.Message.setMessageFailedById(databaseMessage.id, "timeout");
}, message.estTimeout);
}
static async syncMessages() {