Skip to content

Commit

Permalink
fix: update meeting name after fetch meetinginfo (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsarika authored Oct 10, 2024
1 parent 841a80b commit 20a46f8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/MeetingsSDKAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,11 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter {
tap((meeting) => {
const sdkMeeting = this.fetchMeeting(meeting.ID);

this.meetings[meeting.ID] = meeting;
sdkMeeting.emit(EVENT_MEETING_UPDATED, meeting);
this.meetings[meeting.ID] = {
...meeting,
title: sdkMeeting.meetingInfo.topic || meeting.title,
};
sdkMeeting.emit(EVENT_MEETING_UPDATED, this.meetings[meeting.ID]);
}),
catchError((err) => {
logger.error('MEETING', destination, 'createMeeting()', `Unable to create a meeting with "${destination}"`, err);
Expand Down Expand Up @@ -661,6 +664,10 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter {
}),
}));
} else {
// update the meeting title if available after password verification
if (sdkMeeting.meetingInfo.topic) {
this.updateMeeting(ID, () => ({title: sdkMeeting.meetingInfo.topic}));
}
logger.info('MEETING', ID, 'joinMeeting()', 'Password successfully verified');
}
}
Expand Down
33 changes: 33 additions & 0 deletions src/MeetingsSDKAdapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,39 @@ describe('Meetings SDK Adapter', () => {
});
});

it('should emit EVENT_MEETING_UPDATED with the updated title from sdkMeeting.meetingInfo.topic', (done) => {
// Mock implementations
meetingsSDKAdapter.getLocalMedia = jest.fn(() => rxjs.of({
localAudio: {
stream: mockSDKMediaStreams.localAudio,
permission: 'ALLOWED',
},
localVideo: {
stream: mockSDKMediaStreams.localVideo,
permission: 'ALLOWED',
},
}));

// Mock fetchMeeting to return an object containing meetingInfo.topic and an emit function
const mockEmit = jest.fn();

meetingsSDKAdapter.fetchMeeting = jest.fn(() => ({
meetingInfo: {
topic: 'Updated Meeting Title',
},
emit: mockEmit,
}));

meetingsSDKAdapter.createMeeting(target).pipe(last()).subscribe(() => {
// Ensure the emit function was called with the updated meeting
expect(mockEmit).toHaveBeenCalledWith('adapter:meeting:updated', expect.objectContaining({
title: 'Updated Meeting Title',
}));

done();
});
});

it('throws error on failed meeting push request', (done) => {
const wrongTarget = 'wrongTarget';
const errorMessage = `Unable to create a meeting "${wrongTarget}"`;
Expand Down

0 comments on commit 20a46f8

Please sign in to comment.