Log read sync reception and remove notification

This commit is contained in:
Daniel Gasienica 2018-05-10 17:03:06 -04:00
parent d434262540
commit 24002149f6

View file

@ -24,21 +24,32 @@
message.get('source') === receipt.get('sender')
);
});
if (message) {
Whisper.Notifications.remove(message);
return message.markRead(receipt.get('read_at')).then(
const notificationForMessage = message
? Whisper.Notifications.findWhere({ messageId: message.id })
: null;
const removedNotification = Whisper.Notifications.remove(
notificationForMessage
);
const receiptSender = receipt.get('sender');
const receiptTimestamp = receipt.get('timestamp');
const wasMessageFound = Boolean(message);
const wasNotificationFound = Boolean(notificationForMessage);
const wasNotificationRemoved = Boolean(removedNotification);
console.log('Receive read sync:', {
receiptSender,
receiptTimestamp,
wasMessageFound,
wasNotificationFound,
wasNotificationRemoved,
});
return message
? message.markRead(receipt.get('read_at')).then(
function() {
this.notifyConversation(message);
this.remove(receipt);
}.bind(this)
);
} else {
console.log(
'No message for read sync',
receipt.get('sender'),
receipt.get('timestamp')
);
}
)
: Promise.resolve();
}.bind(this)
);
},