Skip to content

Commit

Permalink
VIH-11245 ignore conference updates that do not match the active conf…
Browse files Browse the repository at this point in the history
…erence
  • Loading branch information
shaed-parkar committed Jan 15, 2025
1 parent fce53e9 commit f90620d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ describe('Conference Reducer', () => {
expect(result.currentConference.caseName).toEqual('Updating conference');
expect(result.currentConference.endpoints[0].pexipInfo).toBeTruthy();
});

it('should ignore the conference if the id does not match the active conference id', () => {
const conferenceWithDifferentId: VHConference = { ...conferenceTestData, id: 'different-id' };
const result = conferenceReducer(
existingInitialState,
ConferenceActions.loadConferenceSuccess({ conference: conferenceWithDifferentId })
);
expect(result).toEqual(existingInitialState);
});
});

describe('leaveConference action', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const updateLoggedInParticipant = (state: ConferenceState, participants: VHParti
export const conferenceReducer = createReducer(
initialState,
on(ConferenceActions.loadConferenceSuccess, (state, { conference }) => {
if (state.currentConference && state.currentConference.id !== conference.id) {
// participants will get updates to other hearings they're booked to on the same day. We only want to update the current conference
// To replace the hearing, dispatch the leaveConference action first
return state;
}
// retain the pexip info and media device status for the participants (this does not come from the API)
const updatedParticipants = conference.participants.map(p => {
const existingParticipant = state.currentConference?.participants.find(cp => cp.id === p.id);
Expand Down

0 comments on commit f90620d

Please sign in to comment.