Conversation: Wait for database fetch to add incoming messages
This commit is contained in:

committed by
Ken Powers

parent
0f9bc57ccb
commit
3e5071e340
@@ -321,6 +321,7 @@
|
||||
this.debouncedUpdateLastMessage();
|
||||
},
|
||||
|
||||
// For outgoing messages, we can call this directly. We're already loaded.
|
||||
addSingleMessage(message) {
|
||||
const { id } = message;
|
||||
const existing = this.messageCollection.get(id);
|
||||
@@ -342,6 +343,15 @@
|
||||
return model;
|
||||
},
|
||||
|
||||
// For incoming messages, they might arrive while we're in the middle of a bulk fetch
|
||||
// from the database. We'll wait until that is done to process this newly-arrived
|
||||
// message.
|
||||
async addIncomingMessage(message) {
|
||||
await this.inProgressFetch;
|
||||
|
||||
this.addSingleMessage(message);
|
||||
},
|
||||
|
||||
format() {
|
||||
return this.cachedProps;
|
||||
},
|
||||
|
Reference in New Issue
Block a user