diff --git a/app/actions/websocket/index.ts b/app/actions/websocket/index.ts index 7d526d048..385d1f9c1 100644 --- a/app/actions/websocket/index.ts +++ b/app/actions/websocket/index.ts @@ -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); } diff --git a/app/products/calls/state/actions.test.ts b/app/products/calls/state/actions.test.ts index 30721001b..0bb680bf4 100644 --- a/app/products/calls/state/actions.test.ts +++ b/app/products/calls/state/actions.test.ts @@ -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, }, }; diff --git a/app/products/calls/state/actions.ts b/app/products/calls/state/actions.ts index 4bfe8976b..74cfed3fd 100644 --- a/app/products/calls/state/actions.ts +++ b/app/products/calls/state/actions.ts @@ -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) => {