Remove redundant listenTo calls in ConversationModel#fetchContacts

This commit is contained in:
Evan Hahn 2021-03-29 15:43:31 -05:00 committed by GitHub
parent 7a3130a795
commit 902e48e308
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -230,6 +230,12 @@ export class ConversationModel extends window.Backbone.Model<
this.debouncedUpdateLastMessage, this.debouncedUpdateLastMessage,
this this
); );
if (!this.isPrivate()) {
this.contactCollection.on(
'change:verified',
this.onMemberVerifiedChange.bind(this)
);
}
this.messageCollection = new window.Whisper.MessageCollection([], { this.messageCollection = new window.Whisper.MessageCollection([], {
conversation: this, conversation: this,
@ -1986,8 +1992,6 @@ export class ConversationModel extends window.Backbone.Model<
} }
}) })
); );
this.onMemberVerifiedChange();
} }
setVerifiedDefault(options?: VerificationOptions): Promise<unknown> { setVerifiedDefault(options?: VerificationOptions): Promise<unknown> {
@ -4750,14 +4754,7 @@ export class ConversationModel extends window.Backbone.Model<
} }
fetchContacts(): void { fetchContacts(): void {
if (this.isPrivate()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.contactCollection!.reset([this]);
}
const members = this.getMembers(); const members = this.getMembers();
window._.forEach(members, member => {
this.listenTo(member, 'change:verified', this.onMemberVerifiedChange);
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.contactCollection!.reset(members); this.contactCollection!.reset(members);