Fix doGroupCallPeek to skip direct conversations

This commit is contained in:
ayumi-signal 2024-03-15 10:21:59 -07:00 committed by GitHub
parent 73c0e0eb18
commit 8a21f8655f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,7 +54,7 @@ import type {
ConversationChangedActionType, ConversationChangedActionType,
ConversationRemovedActionType, ConversationRemovedActionType,
} from './conversations'; } from './conversations';
import { updateLastMessage } from './conversations'; import { getConversationCallMode, updateLastMessage } from './conversations';
import * as log from '../../logging/log'; import * as log from '../../logging/log';
import { strictAssert } from '../../util/assert'; import { strictAssert } from '../../util/assert';
import { waitForOnline } from '../../util/waitForOnline'; import { waitForOnline } from '../../util/waitForOnline';
@ -75,6 +75,7 @@ import {
import type { ShowErrorModalActionType } from './globalModals'; import type { ShowErrorModalActionType } from './globalModals';
import { SHOW_ERROR_MODAL } from './globalModals'; import { SHOW_ERROR_MODAL } from './globalModals';
import { ButtonVariant } from '../../components/Button'; import { ButtonVariant } from '../../components/Button';
import { getConversationIdForLogging } from '../../util/idForLogging';
// State // State
@ -420,14 +421,28 @@ const doGroupCallPeek = ({
>; >;
getState: () => RootStateType; getState: () => RootStateType;
}) => { }) => {
let logId: string;
if (callMode === CallMode.Group) {
const conversation = getOwn( const conversation = getOwn(
getState().conversations.conversationLookup, getState().conversations.conversationLookup,
conversationId conversationId
); );
if (!conversation || !isGroupOrAdhocCallMode(callMode)) { if (
!conversation ||
getConversationCallMode(conversation) !== CallMode.Group
) {
return; return;
} }
logId = getConversationIdForLogging(conversation);
} else {
const callLink = getOwn(getState().calling.callLinks, conversationId);
if (!callLink) {
return;
}
logId = `adhoc(${conversationId})`;
}
let queue = peekQueueByConversation.get(conversationId); let queue = peekQueueByConversation.get(conversationId);
if (!queue) { if (!queue) {
queue = new LatestQueue(); queue = new LatestQueue();
@ -469,6 +484,7 @@ const doGroupCallPeek = ({
if (callMode === CallMode.Group) { if (callMode === CallMode.Group) {
peekInfo = await calling.peekGroupCall(conversationId); peekInfo = await calling.peekGroupCall(conversationId);
} else { } else {
// For adhoc calls, conversationId is actually a roomId.
const rootKey: string | undefined = getOwn( const rootKey: string | undefined = getOwn(
state.calling.callLinks, state.calling.callLinks,
conversationId conversationId
@ -484,9 +500,7 @@ const doGroupCallPeek = ({
return; return;
} }
log.info( log.info(`doGroupCallPeek/${logId}: Found ${peekInfo.deviceCount} devices`);
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
);
if (callMode === CallMode.Group) { if (callMode === CallMode.Group) {
const joinState = isGroupOrAdhocCallState(existingCall) const joinState = isGroupOrAdhocCallState(existingCall)
@ -505,6 +519,8 @@ const doGroupCallPeek = ({
Errors.toLogFormat(error) Errors.toLogFormat(error)
); );
} }
dispatch(updateLastMessage(conversationId));
} }
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo); const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo);
@ -517,8 +533,6 @@ const doGroupCallPeek = ({
peekInfo: formattedPeekInfo, peekInfo: formattedPeekInfo,
}, },
}); });
dispatch(updateLastMessage(conversationId));
}); });
}; };
@ -2611,13 +2625,16 @@ export function reducer(
if (action.type === PEEK_GROUP_CALL_FULFILLED) { if (action.type === PEEK_GROUP_CALL_FULFILLED) {
const { callMode, conversationId, peekInfo } = action.payload; const { callMode, conversationId, peekInfo } = action.payload;
if (!isGroupOrAdhocCallMode(callMode)) {
return state;
}
const existingCall: GroupCallStateType = getGroupCall( const existingCall: GroupCallStateType = getGroupCall(
conversationId, conversationId,
state, state,
callMode callMode
) || { ) || {
callMode: CallMode.Group, callMode,
conversationId, conversationId,
connectionState: GroupCallConnectionState.NotConnected, connectionState: GroupCallConnectionState.NotConnected,
joinState: GroupCallJoinState.NotJoined, joinState: GroupCallJoinState.NotJoined,