Move left pane entirely to React

This commit is contained in:
Scott Nonnenberg 2019-01-14 13:49:58 -08:00
parent bf904ddd12
commit b3ac1373fa
142 changed files with 5016 additions and 3428 deletions

View file

@ -83,6 +83,42 @@
this.on('unload', this.unload);
this.on('expired', this.onExpired);
this.setToExpire();
// Keep props ready
const generateProps = () => {
if (this.isExpirationTimerUpdate()) {
this.propsForTimerNotification = this.getPropsForTimerNotification();
} else if (this.isKeyChange()) {
this.propsForSafetyNumberNotification = this.getPropsForSafetyNumberNotification();
} else if (this.isVerifiedChange()) {
this.propsForVerificationNotification = this.getPropsForVerificationNotification();
} else if (this.isEndSession()) {
this.propsForResetSessionNotification = this.getPropsForResetSessionNotification();
} else if (this.isGroupUpdate()) {
this.propsForGroupNotification = this.getPropsForGroupNotification();
} else {
this.propsForSearchResult = this.getPropsForSearchResult();
this.propsForMessage = this.getPropsForMessage();
}
};
this.on('change', generateProps);
const applicableConversationChanges =
'change:color change:name change:number change:profileName change:profileAvatar';
const conversation = this.getConversation();
const fromContact = this.getIncomingContact();
this.listenTo(conversation, applicableConversationChanges, generateProps);
if (fromContact) {
this.listenTo(
fromContact,
applicableConversationChanges,
generateProps
);
}
generateProps();
},
idForLogging() {
return `${this.get('source')}.${this.get('sourceDevice')} ${this.get(
@ -387,6 +423,35 @@
return 'sending';
},
getPropsForSearchResult() {
const fromNumber = this.getSource();
const from = this.findAndFormatContact(fromNumber);
if (fromNumber === this.OUR_NUMBER) {
from.isMe = true;
}
const toNumber = this.get('conversationId');
let to = this.findAndFormatContact(toNumber);
if (toNumber === this.OUR_NUMBER) {
to.isMe = true;
} else if (fromNumber === toNumber) {
to = {
isMe: true,
};
}
return {
from,
to,
isSelected: this.isSelected,
id: this.id,
conversationId: this.get('conversationId'),
receivedAt: this.get('received_at'),
snippet: this.get('snippet'),
};
},
getPropsForMessage() {
const phoneNumber = this.getSource();
const contact = this.findAndFormatContact(phoneNumber);
@ -495,7 +560,7 @@
// Would be nice to do this before render, on initial load of message
if (!window.isSignalAccountCheckComplete(firstNumber)) {
window.checkForSignalAccount(firstNumber).then(() => {
this.trigger('change');
this.trigger('change', this);
});
}