Only notify for group calls once
This commit is contained in:
parent
3268d3e6eb
commit
1f963efd64
3 changed files with 53 additions and 28 deletions
|
@ -113,7 +113,7 @@ import {
|
|||
getLocalCallEventFromCallEndedReason,
|
||||
getCallDetailsFromEndedDirectCall,
|
||||
getCallEventDetails,
|
||||
getLocalCallEventFromGroupCall,
|
||||
getLocalCallEventFromJoinState,
|
||||
getLocalCallEventFromDirectCall,
|
||||
getCallDetailsFromDirectCall,
|
||||
getCallDetailsFromGroupCallMeta,
|
||||
|
@ -121,6 +121,7 @@ import {
|
|||
getGroupCallMeta,
|
||||
getCallIdFromRing,
|
||||
getLocalCallEventFromRingUpdate,
|
||||
convertJoinState,
|
||||
} from '../util/callDisposition';
|
||||
import { isNormalNumber } from '../util/isNormalNumber';
|
||||
import { LocalCallEvent } from '../types/CallDisposition';
|
||||
|
@ -718,8 +719,8 @@ export class CallingClass {
|
|||
|
||||
if (groupCallMeta != null) {
|
||||
try {
|
||||
const localCallEvent = getLocalCallEventFromGroupCall(
|
||||
groupCall,
|
||||
const localCallEvent = getLocalCallEventFromJoinState(
|
||||
convertJoinState(localDeviceState.joinState),
|
||||
groupCallMeta
|
||||
);
|
||||
|
||||
|
@ -844,7 +845,11 @@ export class CallingClass {
|
|||
void this.sendGroupCallUpdateMessage(conversationId, eraId);
|
||||
}
|
||||
|
||||
void this.updateCallHistoryForGroupCall(conversationId, peekInfo);
|
||||
void this.updateCallHistoryForGroupCall(
|
||||
conversationId,
|
||||
convertJoinState(localDeviceState.joinState),
|
||||
peekInfo
|
||||
);
|
||||
this.syncGroupCallToRedux(conversationId, groupCall);
|
||||
},
|
||||
async requestMembershipProof(groupCall) {
|
||||
|
@ -2256,6 +2261,7 @@ export class CallingClass {
|
|||
|
||||
public async updateCallHistoryForGroupCall(
|
||||
conversationId: string,
|
||||
joinState: GroupCallJoinState,
|
||||
peekInfo: PeekInfo | null
|
||||
): Promise<void> {
|
||||
const groupCallMeta = getGroupCallMeta(peekInfo);
|
||||
|
@ -2282,10 +2288,9 @@ export class CallingClass {
|
|||
|
||||
const isNewCall = prevMessageId == null;
|
||||
|
||||
const groupCall = this.getGroupCall(conversationId);
|
||||
if (groupCall != null) {
|
||||
const localCallEvent = getLocalCallEventFromGroupCall(
|
||||
groupCall,
|
||||
if (isNewCall) {
|
||||
const localCallEvent = getLocalCallEventFromJoinState(
|
||||
joinState,
|
||||
groupCallMeta
|
||||
);
|
||||
if (localCallEvent != null) {
|
||||
|
|
|
@ -372,7 +372,13 @@ const doGroupCallPeek = (
|
|||
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
|
||||
);
|
||||
|
||||
await calling.updateCallHistoryForGroupCall(conversationId, peekInfo);
|
||||
if (existingCall?.callMode === CallMode.Group) {
|
||||
await calling.updateCallHistoryForGroupCall(
|
||||
conversationId,
|
||||
existingCall.joinState,
|
||||
peekInfo
|
||||
);
|
||||
}
|
||||
|
||||
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo);
|
||||
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import Long from 'long';
|
||||
import type {
|
||||
Call,
|
||||
GroupCall,
|
||||
PeekInfo,
|
||||
LocalDeviceState,
|
||||
} from '@signalapp/ringrtc';
|
||||
import type { Call, PeekInfo, LocalDeviceState } from '@signalapp/ringrtc';
|
||||
import {
|
||||
CallState,
|
||||
ConnectionState,
|
||||
|
@ -21,7 +16,11 @@ import { strictAssert } from './assert';
|
|||
import { SignalService as Proto } from '../protobuf';
|
||||
import { bytesToUuid, uuidToBytes } from './uuidToBytes';
|
||||
import { missingCaseError } from './missingCaseError';
|
||||
import { CallEndedReason, CallMode } from '../types/Calling';
|
||||
import {
|
||||
CallEndedReason,
|
||||
CallMode,
|
||||
GroupCallJoinState,
|
||||
} from '../types/Calling';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
import { isMe } from './whatTypeOfConversation';
|
||||
import * as log from '../logging/log';
|
||||
|
@ -137,6 +136,22 @@ export function getPeerIdFromConversation(
|
|||
return conversation.groupId;
|
||||
}
|
||||
|
||||
export function convertJoinState(joinState: JoinState): GroupCallJoinState {
|
||||
if (joinState === JoinState.Joined) {
|
||||
return GroupCallJoinState.Joined;
|
||||
}
|
||||
if (joinState === JoinState.Joining) {
|
||||
return GroupCallJoinState.Joining;
|
||||
}
|
||||
if (joinState === JoinState.NotJoined) {
|
||||
return GroupCallJoinState.NotJoined;
|
||||
}
|
||||
if (joinState === JoinState.Pending) {
|
||||
return GroupCallJoinState.Pending;
|
||||
}
|
||||
throw missingCaseError(joinState);
|
||||
}
|
||||
|
||||
// Call Events <-> Protos
|
||||
// ----------------------
|
||||
|
||||
|
@ -331,34 +346,33 @@ export function getLocalCallEventFromRingUpdate(
|
|||
return ringUpdateToEvent[update];
|
||||
}
|
||||
|
||||
export function getLocalCallEventFromGroupCall(
|
||||
groupCall: GroupCall,
|
||||
export function getLocalCallEventFromJoinState(
|
||||
joinState: GroupCallJoinState,
|
||||
groupCallMeta: GroupCallMeta
|
||||
): LocalCallEvent | null {
|
||||
const direction = getCallDirectionFromRingerId(groupCallMeta.ringerId);
|
||||
const localDeviceState = groupCall.getLocalDeviceState();
|
||||
log.info(
|
||||
'getLocalCallEventFromGroupCall',
|
||||
direction,
|
||||
JoinState[localDeviceState.joinState]
|
||||
GroupCallJoinState[joinState]
|
||||
);
|
||||
if (direction === CallDirection.Incoming) {
|
||||
if (localDeviceState.joinState === JoinState.Joined) {
|
||||
if (joinState === GroupCallJoinState.Joined) {
|
||||
return LocalCallEvent.Accepted;
|
||||
}
|
||||
if (localDeviceState.joinState === JoinState.NotJoined) {
|
||||
return null; // Group calls shouldn't send "NotAccepted"
|
||||
if (joinState === GroupCallJoinState.NotJoined) {
|
||||
return LocalCallEvent.Started;
|
||||
}
|
||||
if (
|
||||
localDeviceState.joinState === JoinState.Joining ||
|
||||
localDeviceState.joinState === JoinState.Pending
|
||||
joinState === GroupCallJoinState.Joining ||
|
||||
joinState === GroupCallJoinState.Pending
|
||||
) {
|
||||
return LocalCallEvent.Accepted;
|
||||
}
|
||||
throw missingCaseError(localDeviceState.joinState);
|
||||
throw missingCaseError(joinState);
|
||||
} else {
|
||||
if (localDeviceState.joinState === JoinState.NotJoined) {
|
||||
return LocalCallEvent.Hangup;
|
||||
if (joinState === GroupCallJoinState.NotJoined) {
|
||||
return LocalCallEvent.Started;
|
||||
}
|
||||
return LocalCallEvent.Ringing;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue