ducks/conversations: Ensure metrics agree with in-memory messages

* ducks/conversations: Ensure metrics agree with in-memory messages
* Clean up logic cleaning up metrics
This commit is contained in:
Scott Nonnenberg 2020-01-16 08:45:06 -08:00 committed by Ken Powers
parent 7aaee0cb64
commit 4af7a9ae2c
2 changed files with 25 additions and 4 deletions

View file

@ -795,10 +795,10 @@
let scrollToLatestUnread = true;
if (newestMessageId) {
const message = await getMessageById(newestMessageId, {
const newestInMemoryMessage = await getMessageById(newestMessageId, {
Message: Whisper.Message,
});
if (!message) {
if (!newestInMemoryMessage) {
window.log.warn(
`loadNewestMessages: did not find message ${newestMessageId}`
);
@ -806,7 +806,9 @@
// If newest in-memory message is unread, scrolling down would mean going to
// the very bottom, not the oldest unread.
scrollToLatestUnread = !message.isUnread();
if (newestInMemoryMessage.isUnread()) {
scrollToLatestUnread = false;
}
}
const metrics = await getMessageMetricsForConversation(conversationId);