Skip to content

Commit

Permalink
fix messageSent indicators for Reply messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Sep 9, 2024
1 parent 80b2fbf commit 19f4993
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,26 @@ export class ReceiptDispatcher {
contactAliasName: string,
messageModel: MessageModel,
) {
//We only want to acknowledge messages from type NEW. Every other message type can be neglected for now
const msgIsNew = messageModel.envelop.message.metadata.type === 'NEW';
//We only want to acknowledge messages from type NEW or REPLY. Every other message type can be neglected for now
const shouldAcknowledgeMessage =
messageModel.envelop.message.metadata.type === 'NEW' ||
messageModel.envelop.message.metadata.type === 'REPLY';
//Check if the selected contact is the sender of the message.
// If that is the case we've to acknowledge the message and send a READ_OPENED acknowledgement to the sender
const selectedContactIsSender =
selectedContact?.contactDetails.account.ensName ===
contactAliasName;

//We acknowledge that we've received the message by sending a READ_RECEIVED acknowledgement to the sender
if (msgIsNew) {
if (shouldAcknowledgeMessage) {
await this.sendReceivedReceipte(contactAliasName, messageModel);
console.log('sent received receipt to ', contactAliasName);
}

if (msgIsNew && selectedContactIsSender) {
if (shouldAcknowledgeMessage && selectedContactIsSender) {
// if contact is selected then send READ_OPENED acknowledgement to sender for new message received
await this.sendOpendReceipt(contactAliasName, messageModel);
console.log('sent opend receipt to ', contactAliasName);
console.log('sent opened receipt to ', contactAliasName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export const handleMessagesFromWebSocket = async (
// Resolve TLD to alias
const contact = contactPreview?.contactDetails.account.ensName!;

console.log('contactPreview MSGWS', contactPreview);

const messageState =
selectedContact?.contactDetails.account.ensName === contact
? MessageState.Read
Expand Down

0 comments on commit 19f4993

Please sign in to comment.