Skip to content

Commit ed2b218

Browse files
authored
avoid fetching contacts in a loop (#2852)
when contacts are missing in database it's refetching them all the time.
1 parent 200ce07 commit ed2b218

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

client/components/Contacts/ContactsPreviewList.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const mapDispatchToProps = (dispatch) => ({
3434
fetchContacts: (ids) => dispatch(actions.contacts.fetchContactsByIds(ids)),
3535
});
3636

37-
class ContactsPreviewListComponent extends React.Component<IProps, IState> {
37+
class ContactsPreviewListComponent extends React.PureComponent<IProps, IState> {
3838
_isMounted: boolean;
3939

4040
constructor(props) {
@@ -55,11 +55,8 @@ class ContactsPreviewListComponent extends React.Component<IProps, IState> {
5555
fetchContactsRequired() {
5656
return (
5757
!this.state.fetchingContacts &&
58-
difference(
59-
this.props.contactIds || [],
60-
Object.keys(this.props.contacts || {})
61-
).length > 0
62-
) || !isEqual(this.state.fetchingIds, this.props.contactIds);
58+
!isEqual(this.state.fetchingIds, this.props.contactIds)
59+
);
6360
}
6461

6562
fetchContacts() {

0 commit comments

Comments
 (0)