Handle messages with the same received_at

This commit is contained in:
Scott Nonnenberg 2020-07-06 10:06:44 -07:00
parent 82bf517a69
commit e536929e35
5 changed files with 60 additions and 19 deletions

View file

@ -567,6 +567,7 @@
const receivedAt = message.get('received_at');
const models = await getOlderMessagesByConversation(conversationId, {
receivedAt,
messageId: oldestMessageId,
limit: 500,
MessageCollection: Whisper.MessageCollection,
});
@ -796,6 +797,7 @@
const older = await getOlderMessagesByConversation(conversationId, {
limit: 250,
receivedAt,
messageId,
MessageCollection: Whisper.MessageCollection,
});
const newer = await getNewerMessagesByConversation(conversationId, {
@ -874,11 +876,18 @@
const scrollToMessageId =
setFocus && metrics.newest ? metrics.newest.id : undefined;
// Because our `getOlderMessages` fetch above didn't specify a receivedAt, we got
// the most recent 500 messages in the conversation. If it has a conflict with
// metrics, fetched a bit before, that's likely a race condition. So we tell our
// reducer to trust the message set we just fetched for determining if we have
// the newest message loaded.
const unboundedFetch = true;
messagesReset(
conversationId,
cleaned.map(model => model.getReduxData()),
metrics,
scrollToMessageId
scrollToMessageId,
unboundedFetch
);
} catch (error) {
setMessagesLoading(conversationId, false);
@ -1735,12 +1744,8 @@
window.log.warn(`onOpened: Did not find message ${messageId}`);
}
// Incoming messages may still be processing, so we wait until those are
// complete to pull the 500 most-recent messages in this conversation.
this.model.queueJob(() => {
this.loadNewestMessages();
this.model.updateLastMessage();
});
this.loadNewestMessages();
this.model.updateLastMessage();
this.focusMessageField();