Skip to content

Commit

Permalink
Update group membership for a group call when it changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn-Signal committed Dec 9, 2020
1 parent 3f58a9b commit db0ebc5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
11 changes: 11 additions & 0 deletions ts/services/calling.ts
Expand Up @@ -553,6 +553,17 @@ export class CallingClass {
this.getGroupCall(conversationId)?.requestVideo(resolutions);
}

public groupMembersChanged(conversationId: string): void {
// This will be called for any conversation change, so it's likely that there won't
// be a group call available; that's fine.
const groupCall = this.getGroupCall(conversationId);
if (!groupCall) {
return;
}

groupCall.setGroupMembers(this.getGroupCallMembers(conversationId));
}

// See the comment in types/Calling.ts to explain why we have to do this conversion.
private convertRingRtcConnectionState(
connectionState: ConnectionState
Expand Down
21 changes: 14 additions & 7 deletions ts/state/ducks/conversations.ts
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only

/* eslint-disable camelcase */
import { ThunkAction } from 'redux-thunk';
import {
difference,
fromPairs,
Expand All @@ -14,6 +15,8 @@ import {
without,
} from 'lodash';

import { StateType as RootStateType } from '../reducer';
import { calling } from '../../services/calling';
import { getOwn } from '../../util/getOwn';
import { trigger } from '../../shims/events';
import { NoopActionType } from './noop';
Expand Down Expand Up @@ -454,13 +457,17 @@ function conversationAdded(
function conversationChanged(
id: string,
data: ConversationType
): ConversationChangedActionType {
return {
type: 'CONVERSATION_CHANGED',
payload: {
id,
data,
},
): ThunkAction<void, RootStateType, unknown, ConversationChangedActionType> {
return dispatch => {
calling.groupMembersChanged(id);

dispatch({
type: 'CONVERSATION_CHANGED',
payload: {
id,
data,
},
});
};
}
function conversationRemoved(id: string): ConversationRemovedActionType {
Expand Down

0 comments on commit db0ebc5

Please sign in to comment.