MM-45972 - Calls: test ws messages when app is in background (#6720)
* update current call on reconnect * move loadConfigAndCalls above deferredAppEntryActions
This commit is contained in:
parent
1d4806d7b0
commit
e38e547ce2
3 changed files with 50 additions and 6 deletions
|
|
@ -179,12 +179,13 @@ async function doReconnect(serverUrl: string) {
|
|||
|
||||
const {id: currentUserId, locale: currentUserLocale} = (await getCurrentUser(database))!;
|
||||
const {config, license} = await getCommonSystemValues(database);
|
||||
await deferredAppEntryActions(serverUrl, lastDisconnectedAt, currentUserId, currentUserLocale, prefData.preferences, config, license, teamData, chData, initialTeamId, switchedToChannel ? initialChannelId : undefined);
|
||||
|
||||
if (isSupportedServerCalls(config?.Version)) {
|
||||
loadConfigAndCalls(serverUrl, currentUserId);
|
||||
}
|
||||
|
||||
await deferredAppEntryActions(serverUrl, lastDisconnectedAt, currentUserId, currentUserLocale, prefData.preferences, config, license, teamData, chData, initialTeamId, switchedToChannel ? initialChannelId : undefined);
|
||||
|
||||
AppsManager.refreshAppBindings(serverUrl);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,39 +107,68 @@ describe('useCallsState', () => {
|
|||
const initialChannelsWithCallsState = {
|
||||
'channel-1': true,
|
||||
};
|
||||
const initialCurrentCallState: CurrentCall = {
|
||||
serverUrl: 'server1',
|
||||
myUserId: 'myUserId',
|
||||
...call1,
|
||||
screenShareURL: '',
|
||||
speakerphoneOn: false,
|
||||
};
|
||||
const testNewCall1 = {
|
||||
...call1,
|
||||
participants: {
|
||||
'user-1': {id: 'user-1', muted: false, raisedHand: 0},
|
||||
'user-2': {id: 'user-2', muted: true, raisedHand: 0},
|
||||
'user-3': {id: 'user-3', muted: false, raisedHand: 123},
|
||||
},
|
||||
};
|
||||
const test = {
|
||||
calls: {'channel-1': call2, 'channel-2': call3},
|
||||
calls: {'channel-1': testNewCall1, 'channel-2': call2, 'channel-3': call3},
|
||||
enabled: {'channel-2': true},
|
||||
};
|
||||
|
||||
const expectedCallsState = {
|
||||
...initialCallsState,
|
||||
serverUrl: 'server1',
|
||||
myUserId: 'myId',
|
||||
calls: {'channel-1': call2, 'channel-2': call3},
|
||||
calls: {'channel-1': testNewCall1, 'channel-2': call2, 'channel-3': call3},
|
||||
enabled: {'channel-2': true},
|
||||
};
|
||||
const expectedChannelsWithCallsState = {
|
||||
...initialChannelsWithCallsState,
|
||||
'channel-2': true,
|
||||
'channel-3': true,
|
||||
};
|
||||
const expectedCurrentCallState = {
|
||||
...initialCurrentCallState,
|
||||
...testNewCall1,
|
||||
};
|
||||
|
||||
// setup
|
||||
const {result} = renderHook(() => {
|
||||
return [useCallsState('server1'), useCallsState('server1'), useChannelsWithCalls('server1')];
|
||||
return [
|
||||
useCallsState('server1'),
|
||||
useCallsState('server1'),
|
||||
useChannelsWithCalls('server1'),
|
||||
useCurrentCall(),
|
||||
];
|
||||
});
|
||||
act(() => {
|
||||
setCallsState('server1', initialCallsState);
|
||||
setChannelsWithCalls('server1', initialChannelsWithCallsState);
|
||||
setCurrentCall(initialCurrentCallState);
|
||||
});
|
||||
assert.deepEqual(result.current[0], initialCallsState);
|
||||
assert.deepEqual(result.current[1], initialCallsState);
|
||||
assert.deepEqual(result.current[2], initialChannelsWithCallsState);
|
||||
assert.deepEqual(result.current[3], initialCurrentCallState);
|
||||
|
||||
// test
|
||||
act(() => setCalls('server1', 'myId', test.calls, test.enabled));
|
||||
assert.deepEqual(result.current[0], expectedCallsState);
|
||||
assert.deepEqual(result.current[1], expectedCallsState);
|
||||
assert.deepEqual(result.current[2], expectedChannelsWithCallsState);
|
||||
assert.deepEqual(result.current[3], expectedCurrentCallState);
|
||||
});
|
||||
|
||||
it('joinedCall', () => {
|
||||
|
|
@ -469,7 +498,8 @@ describe('useCallsState', () => {
|
|||
};
|
||||
const expectedCallsState = {
|
||||
...initialCallsState,
|
||||
calls: {...initialCallsState.calls,
|
||||
calls: {
|
||||
...initialCallsState.calls,
|
||||
'channel-1': newCall1,
|
||||
},
|
||||
};
|
||||
|
|
@ -589,7 +619,8 @@ describe('useCallsState', () => {
|
|||
};
|
||||
const expectedCallsState = {
|
||||
...initialCallsState,
|
||||
calls: {...initialCallsState.calls,
|
||||
calls: {
|
||||
...initialCallsState.calls,
|
||||
'channel-1': newCall1,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,18 @@ export const setCalls = (serverUrl: string, myUserId: string, calls: Dictionary<
|
|||
setChannelsWithCalls(serverUrl, channelsWithCalls);
|
||||
|
||||
setCallsState(serverUrl, {serverUrl, myUserId, calls, enabled});
|
||||
|
||||
// Does the current call need to be updated?
|
||||
const currentCall = getCurrentCall();
|
||||
if (!currentCall || !calls[currentCall.channelId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextCall = {
|
||||
...currentCall,
|
||||
...calls[currentCall.channelId],
|
||||
};
|
||||
setCurrentCall(nextCall);
|
||||
};
|
||||
|
||||
export const setCallForChannel = (serverUrl: string, channelId: string, enabled: boolean, call?: Call) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue