Put presenter state in conference manager
This commit is contained in:
parent
1661c5518b
commit
23763422d8
2 changed files with 19 additions and 8 deletions
|
@ -247,6 +247,7 @@ export class ConferenceCallManager extends EventEmitter {
|
||||||
stream,
|
stream,
|
||||||
audioMuted: this.audioMuted,
|
audioMuted: this.audioMuted,
|
||||||
videoMuted: this.videoMuted,
|
videoMuted: this.videoMuted,
|
||||||
|
presenter: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.participants.push(this.localParticipant);
|
this.participants.push(this.localParticipant);
|
||||||
|
@ -400,6 +401,17 @@ export class ConferenceCallManager extends EventEmitter {
|
||||||
this.emit("participants_changed");
|
this.emit("participants_changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPresenter(userId, presenter) {
|
||||||
|
const participant = this.participants.find(
|
||||||
|
(participant) => participant.userId === userId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (participant) {
|
||||||
|
participant.presenter = presenter;
|
||||||
|
this.emit("participants_changed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
localStorage.removeItem("matrix-auth-store");
|
localStorage.removeItem("matrix-auth-store");
|
||||||
}
|
}
|
||||||
|
@ -533,6 +545,7 @@ export class ConferenceCallManager extends EventEmitter {
|
||||||
stream,
|
stream,
|
||||||
audioMuted,
|
audioMuted,
|
||||||
videoMuted,
|
videoMuted,
|
||||||
|
presenter: false,
|
||||||
};
|
};
|
||||||
this.participants.push(participant);
|
this.participants.push(participant);
|
||||||
}
|
}
|
||||||
|
@ -632,6 +645,7 @@ export class ConferenceCallManager extends EventEmitter {
|
||||||
stream: null,
|
stream: null,
|
||||||
audioMuted: false,
|
audioMuted: false,
|
||||||
videoMuted: false,
|
videoMuted: false,
|
||||||
|
presenter: false,
|
||||||
};
|
};
|
||||||
// TODO: Should we wait until the call has been answered to push the participant?
|
// TODO: Should we wait until the call has been answered to push the participant?
|
||||||
// Or do we hide the participant until their stream is live?
|
// Or do we hide the participant until their stream is live?
|
||||||
|
|
|
@ -340,16 +340,13 @@ export function useVideoRoom(manager, roomId, timeout = 5000) {
|
||||||
}, [manager]);
|
}, [manager]);
|
||||||
|
|
||||||
const togglePresenter = useCallback((selectedParticipant) => {
|
const togglePresenter = useCallback((selectedParticipant) => {
|
||||||
|
manager.setPresenter(
|
||||||
|
selectedParticipant.userId,
|
||||||
|
!selectedParticipant.presenter
|
||||||
|
);
|
||||||
setState((prevState) => ({
|
setState((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
participants: prevState.participants.map((participant) =>
|
participants: [...manager.participants],
|
||||||
participant === selectedParticipant
|
|
||||||
? {
|
|
||||||
...participant,
|
|
||||||
presenter: !participant.presenter,
|
|
||||||
}
|
|
||||||
: participant
|
|
||||||
),
|
|
||||||
}));
|
}));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue