From 623f3da4a2f9252e24c3338c16fc2cc33cedc779 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 4 Jun 2021 13:38:14 +1000 Subject: [PATCH] avoid refreshing mentions too often --- .../session/conversation/SessionConversation.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ts/components/session/conversation/SessionConversation.tsx b/ts/components/session/conversation/SessionConversation.tsx index 6679a2e3d..9b55ef9d5 100644 --- a/ts/components/session/conversation/SessionConversation.tsx +++ b/ts/components/session/conversation/SessionConversation.tsx @@ -109,7 +109,7 @@ export class SessionConversation extends React.Component { this.compositionBoxRef = React.createRef(); this.messageContainerRef = React.createRef(); this.dragCounter = 0; - this.updateMemberList = _.debounce(this.updateMemberListBouncy, 1000); + this.updateMemberList = _.debounce(this.updateMemberListBouncy.bind(this), 1000); autoBind(this); } @@ -145,9 +145,11 @@ export class SessionConversation extends React.Component { window?.inboxStore?.dispatch(updateMentionsMembers([])); // if the newConversation changed, and is public, start our refresh members list if (newConversation.isPublic) { - // TODO use abort controller to stop those requests too + // this is a debounced call. void this.updateMemberList(); - this.publicMembersRefreshTimeout = global.setInterval(this.updateMemberList, 10000); + // run this only once every minute if we don't change the visible conversation. + // this is a heavy operation (like a few thousands members can be here) + this.publicMembersRefreshTimeout = global.setInterval(this.updateMemberList, 60000); } } // if we do not have a model, unregister for events