From 59398c573e5b35949c2396cc335b9387b78c5131 Mon Sep 17 00:00:00 2001 From: f-r00t Date: Wed, 28 Feb 2024 11:41:29 +0100 Subject: [PATCH] Pop update functions as to not run them too many times --- src/Groups.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Groups.js b/src/Groups.js index 555d995..f3574d3 100644 --- a/src/Groups.js +++ b/src/Groups.js @@ -809,20 +809,22 @@ export class GroupChatScreenNoTranslation extends React.Component { } - Globals.updateGroupsFunctions.push(async () => { - this.setState({ - messages: await getGroupMessages(this.state.key, this.state.messages.length) - }) - }); + } async componentDidMount() { - await markGroupConversationAsRead(this.state.key); + markGroupConversationAsRead(this.state.key); let messages = await getGroupMessages(this.state.key, 25); + Globals.updateGroupsFunctions.push(async () => { + this.setState({ + messages: await getGroupMessages(this.state.key, this.state.messages.length) + }) + }); + if (!messages) { messages = []; } @@ -838,6 +840,7 @@ export class GroupChatScreenNoTranslation extends React.Component { async componentWillUnmount() { Globals.activeChat = ''; + Globals.updateGroupsFunctions.pop(); }