Early preparations for PNP Contact Merging

This commit is contained in:
Scott Nonnenberg 2022-08-09 14:39:00 -07:00 committed by GitHub
parent 2f5dd73e58
commit faf6c41332
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 1572 additions and 447 deletions

View file

@ -44,11 +44,11 @@ export class Reactions extends Collection<ReactionModel> {
const senderId = getContactId(message.attributes);
const sentAt = message.get('sent_at');
const reactionsBySource = this.filter(re => {
const targetSenderId = window.ConversationController.ensureContactIds({
const targetSender = window.ConversationController.lookupOrCreate({
uuid: re.get('targetAuthorUuid'),
});
const targetTimestamp = re.get('targetTimestamp');
return targetSenderId === senderId && targetTimestamp === sentAt;
return targetSender?.id === senderId && targetTimestamp === sentAt;
});
if (reactionsBySource.length > 0) {
@ -87,13 +87,14 @@ export class Reactions extends Collection<ReactionModel> {
try {
// The conversation the target message was in; we have to find it in the database
// to to figure that out.
const targetConversationId =
window.ConversationController.ensureContactIds({
const targetAuthorConversation =
window.ConversationController.lookupOrCreate({
uuid: reaction.get('targetAuthorUuid'),
});
const targetConversationId = targetAuthorConversation?.id;
if (!targetConversationId) {
throw new Error(
'onReaction: No conversationId returned from ensureContactIds!'
'onReaction: No conversationId returned from lookupOrCreate!'
);
}