Safely generate cached conversation props on startup
This commit is contained in:
parent
b32445cd20
commit
67058e27bb
5 changed files with 40 additions and 13 deletions
|
@ -169,11 +169,11 @@
|
|||
this.typingPauseTimer = null;
|
||||
|
||||
// Keep props ready
|
||||
const generateProps = () => {
|
||||
this.generateProps = () => {
|
||||
this.cachedProps = this.getProps();
|
||||
};
|
||||
this.on('change', generateProps);
|
||||
generateProps();
|
||||
this.on('change', this.generateProps);
|
||||
this.generateProps();
|
||||
},
|
||||
|
||||
isMe() {
|
||||
|
@ -444,6 +444,14 @@
|
|||
return this.cachedProps;
|
||||
},
|
||||
getProps() {
|
||||
// This is to prevent race conditions on startup; Conversation models are created
|
||||
// but the full ConversationController.load() sequence isn't complete. So, we
|
||||
// don't cache props on create, but we do later when load() calls generateProps()
|
||||
// for us.
|
||||
if (!window.ConversationController.isFetchComplete()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const color = this.getColor();
|
||||
|
||||
const typingValues = _.values(this.contactTypingTimers || {});
|
||||
|
|
|
@ -664,10 +664,7 @@
|
|||
return ConversationController.get(identifier);
|
||||
},
|
||||
getConversation() {
|
||||
// This needs to be an unsafe call, because this method is called during
|
||||
// initial module setup. We may be in the middle of the initial fetch to
|
||||
// the database.
|
||||
return ConversationController.getUnsafe(this.get('conversationId'));
|
||||
return ConversationController.get(this.get('conversationId'));
|
||||
},
|
||||
createNonBreakingLastSeparator(text) {
|
||||
if (!text) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue