Log read sync reception and remove notification

pull/1/head
Daniel Gasienica 7 years ago
parent d434262540
commit 24002149f6

@ -24,21 +24,32 @@
message.get('source') === receipt.get('sender') message.get('source') === receipt.get('sender')
); );
}); });
if (message) { const notificationForMessage = message
Whisper.Notifications.remove(message); ? Whisper.Notifications.findWhere({ messageId: message.id })
return message.markRead(receipt.get('read_at')).then( : 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() { function() {
this.notifyConversation(message); this.notifyConversation(message);
this.remove(receipt); this.remove(receipt);
}.bind(this) }.bind(this)
); )
} else { : Promise.resolve();
console.log(
'No message for read sync',
receipt.get('sender'),
receipt.get('timestamp')
);
}
}.bind(this) }.bind(this)
); );
}, },

Loading…
Cancel
Save