From ea7a5449f13f2e249f192be93670b3c30d962b25 Mon Sep 17 00:00:00 2001 From: AsamK Date: Fri, 2 Apr 2021 22:32:04 +0200 Subject: [PATCH] Fix race condition which often prevented sending group call started message The group call update message after starting a group call is currently only sent in the onLocalDeviceStateChanged callback. But often the peekInfo is not available yet when the connection state changes to Joined, effectively preventing the group call update message to be sent. This commit also sends the message in the onPeekChanged callback. It is still only sent at most once, which is ensured by the updateMessageState check. See [#5001][0]. [0]: https://github.com/signalapp/Signal-Desktop/pull/5001 --- ts/services/calling.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index f724201ae..70c4d8671 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -478,6 +478,18 @@ export class CallingClass { this.syncGroupCallToRedux(conversationId, groupCall); }, onPeekChanged: groupCall => { + const localDeviceState = groupCall.getLocalDeviceState(); + const { eraId } = groupCall.getPeekInfo() || {}; + if ( + updateMessageState === GroupCallUpdateMessageState.SentNothing && + localDeviceState.connectionState !== ConnectionState.NotConnected && + localDeviceState.joinState === JoinState.Joined && + eraId + ) { + updateMessageState = GroupCallUpdateMessageState.SentJoin; + this.sendGroupCallUpdateMessage(conversationId, eraId); + } + this.updateCallHistoryForGroupCall( conversationId, groupCall.getPeekInfo()