Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #703 from SuperViz/fix/kick-participant-interval
Browse files Browse the repository at this point in the history
fix: retrieve user list from store to validade if room has host
  • Loading branch information
carlossantos74 authored Jul 3, 2024
2 parents 5845883 + 43522ef commit b3a06f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/video/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('VideoConference', () => {

VideoConferenceInstance['onRealtimeParticipantsDidChange'](secondList);

expect(VideoConferenceInstance['roomState'].setHost).toHaveBeenCalledTimes(1);
expect(VideoConferenceInstance['roomState'].setHost).toHaveBeenCalledTimes(0);
});

test('should not set host if the participant is not me', () => {
Expand Down
12 changes: 9 additions & 3 deletions src/components/video/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,15 @@ export class VideoConference extends BaseComponent {
if (!this.roomState) return;

const { hostId } = this.useStore(StoreType.VIDEO);
const { participants } = this.useStore(StoreType.GLOBAL);
const participantsList = Object.values(participants.value);

const participantsCanBeHost = this.participantsOnMeeting.filter((participant) => {
return participant.type === ParticipantType.HOST;
// list with all participants that have the type host and are in the meeting
const participantsCanBeHost = participantsList.filter((participant) => {
return (
participant.type === ParticipantType.HOST &&
this.participantsOnMeeting.some((p) => p.id === participant.id)
);
});

if (
Expand Down Expand Up @@ -848,7 +854,7 @@ export class VideoConference extends BaseComponent {

this.onHostAvailabilityChange(!!participantsCanBeHost.length);

const hostAlreadyInRoom = participantsCanBeHost.find(
const hostAlreadyInRoom = participantsList.find(
(participant) => participant?.id === hostId?.value,
);

Expand Down

0 comments on commit b3a06f3

Please sign in to comment.