Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flat-stores): joiner off stage leaves window #1856

Merged
merged 3 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ export const GeneralSettingPage = observer(function GeneralSettingPage() {
<div className="general-setting-join-options-box">
<div className="general-setting-join-options">{t("join-options")}</div>
<Checkbox
value={preferencesStore.autoMicOn}
checked={preferencesStore.autoMicOn}
onClick={() =>
preferencesStore.updateAutoMicOn(!preferencesStore.autoMicOn)
}
>
{t("turn-on-the-microphone")}
</Checkbox>
<Checkbox
value={preferencesStore.autoCameraOn}
checked={preferencesStore.autoCameraOn}
onClick={() =>
preferencesStore.updateAutoCameraOn(!preferencesStore.autoCameraOn)
}
Expand Down
21 changes: 12 additions & 9 deletions packages/flat-stores/src/classroom-store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ export class ClassroomStore {
if (!this.isCreator) {
const isJoinerOnStage = Boolean(onStageUsersStorage.state[this.userUUID]);
this.whiteboardStore.updateWritable(
isJoinerOnStage || whiteboardStorage.state[this.userUUID],
Boolean(isJoinerOnStage || whiteboardStorage.state[this.userUUID]),
);
this.whiteboardStore.updateAllowDrawing(whiteboardStorage.state[this.userUUID]);

Expand Down Expand Up @@ -595,9 +595,11 @@ export class ClassroomStore {
!!whiteboardStorage.state[user.userUUID];
});
this.whiteboardStore.updateWritable(
this.isCreator ||
onStageUsersStorage.state[this.userUUID] ||
whiteboardStorage.state[this.userUUID],
Boolean(
this.isCreator ||
onStageUsersStorage.state[this.userUUID] ||
whiteboardStorage.state[this.userUUID],
),
);
this.whiteboardStore.updateAllowDrawing(
this.isCreator || whiteboardStorage.state[this.userUUID],
Expand Down Expand Up @@ -837,7 +839,8 @@ export class ClassroomStore {
};

public deleteAvatarWindow = (userUUID: string): void => {
if (this.isCreator && this.userWindowsStorage) {
// joiners can delete themselves
if (this.userWindowsStorage?.isWritable) {
this.userWindowsStorage.setState({ [userUUID]: undefined });
let grid = this.userWindowsStorage.state.grid;
if (grid && grid.includes(userUUID)) {
Expand Down Expand Up @@ -997,6 +1000,10 @@ export class ClassroomStore {
) {
return;
}
if (!onStage && (!this.isCreator || userUUID !== this.userUUID)) {
this.updateDeviceState(userUUID, false, false);
this.deleteAvatarWindow(userUUID);
}
if (this.isCreator) {
if (!onStage || this.assertStageNotFull()) {
this.onStageUsersStorage.setState({ [userUUID]: onStage });
Expand All @@ -1010,10 +1017,6 @@ export class ClassroomStore {
this.onStageUsersStorage.setState({ [userUUID]: false });
}
}
if (!onStage && (!this.isCreator || userUUID !== this.userUUID)) {
this.updateDeviceState(userUUID, false, false);
this.deleteAvatarWindow(userUUID);
}
if (this.classroomStorage?.state.raiseHandUsers.includes(userUUID)) {
const raiseHandUsers = this.classroomStorage.state.raiseHandUsers;
this.classroomStorage.setState({
Expand Down