Skip to content

Commit

Permalink
feat(flat-pages): add option to hide others' cursor names (#1934)
Browse files Browse the repository at this point in the history
- remove share with audio option on macOS in electron
  • Loading branch information
hyrious authored May 12, 2023
1 parent e490257 commit cdffb42
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"join-options": "Join Options",
"create-room-default-title": "The room created by {{name}}",
"turn-on-the-camera": "Camera",
"turn-on-cursor-name": "Show cursor name of others",
"enter-room-uuid": "Please enter the room ID",
"turn-on-the-microphone": "Microphone",
"schedule-room-default-title": "The room scheduled by {{name}}",
Expand Down
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
"begin": "开始",
"join-options": "加入选项",
"turn-on-the-camera": "开启摄像头",
"turn-on-cursor-name": "显示对方光标昵称",
"enter-room-uuid": "请输入房间号",
"turn-on-the-microphone": "开启麦克风",
"schedule-room-default-title": "{{name}} 预定的房间",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@
padding-top: 8px;
}

.general-setting-user-account {
.general-setting-title {
display: block;
margin-bottom: 4px;
}
}

.binding-wechat {
display: inline-flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ export const GeneralSettingPage = observer(function GeneralSettingPage() {
>
{t("turn-on-the-camera")}
</Checkbox>
<Checkbox
checked={preferencesStore.cursorNameOn}
onClick={() =>
preferencesStore.updateCursorNameOn(!preferencesStore.cursorNameOn)
}
>
{t("turn-on-cursor-name")}
</Checkbox>
</div>
<div className="general-setting-device-test-box">
<div className="general-setting-checkbox-title">{t("device-test-option")}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import "./style.less";

import React, { useCallback, useEffect, useLayoutEffect, useState } from "react";
import React, {
useCallback,
useContext,
useEffect,
useLayoutEffect,
useMemo,
useState,
} from "react";
import classNames from "classnames";
import { useTranslate } from "@netless/flat-i18n";
import { ClassroomStore } from "@netless/flat-stores";
Expand All @@ -9,6 +16,7 @@ import { observer } from "mobx-react-lite";
import { IServiceVideoChatDevice } from "@netless/flat-services";
import { useSafePromise } from "flat-components";
import { ScreenList } from "./ScreenList";
import { RuntimeContext } from "../../StoreProvider";

interface ShareScreenPickerProps {
classroomStore: ClassroomStore;
Expand All @@ -20,6 +28,7 @@ const ShareScreenPickerModel = observer<ShareScreenPickerProps>(function ShareSc
handleOk,
}) {
const t = useTranslate();
const runtime = useContext(RuntimeContext);

useLayoutEffect(() => {
classroomStore.refreshShareScreenInfo();
Expand All @@ -31,6 +40,28 @@ const ShareScreenPickerModel = observer<ShareScreenPickerProps>(function ShareSc

const isSelected = classroomStore.selectedScreenInfo !== null;

const chooseSpeaker = useMemo<React.ReactNode>(() => {
if (runtime?.isMac) {
return null;
} else {
return (
<>
<Checkbox
checked={classroomStore.shareScreenWithAudio}
onChange={ev =>
classroomStore.toggleShareScreenWithAudio(ev.target.checked)
}
>
{t("share-screen.with-audio")}
</Checkbox>
{classroomStore.shareScreenWithAudio && (
<ShareScreenSelectSpeaker classroom={classroomStore} />
)}
</>
);
}
}, [classroomStore, runtime, t]);

return (
<div>
<Modal
Expand All @@ -43,17 +74,7 @@ const ShareScreenPickerModel = observer<ShareScreenPickerProps>(function ShareSc
footer={
<Row>
<Col flex={1} style={{ textAlign: "left" }}>
<Checkbox
checked={classroomStore.shareScreenWithAudio}
onChange={ev =>
classroomStore.toggleShareScreenWithAudio(ev.target.checked)
}
>
{t("share-screen.with-audio")}
</Checkbox>
{classroomStore.shareScreenWithAudio && (
<ShareScreenSelectSpeaker classroom={classroomStore} />
)}
{chooseSpeaker}
</Col>
<Col>
<Button key="cancel" className="footer-button" onClick={closeModal}>
Expand Down
6 changes: 6 additions & 0 deletions packages/flat-pages/src/components/Whiteboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
display: revert;
}
}

&.hide-cursor-name {
.netless-window-manager-cursor-name {
display: none;
}
}
}

.telebox-collector {
Expand Down
1 change: 1 addition & 0 deletions packages/flat-pages/src/components/Whiteboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
!classRoomStore.userWindowsGrid &&
(classRoomStore.isCreator ||
classRoomStore.users.currentUser?.wbOperate),
"hide-cursor-name": !preferences.cursorNameOn,
},
)}
/>
Expand Down
7 changes: 7 additions & 0 deletions packages/flat-stores/src/preferences-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export class PreferencesStore {

public background: Background = "default";

/** Show cursor name in room */
public cursorNameOn = true;

/** Turn on recording on joining room */
public autoRecording = false;
/** Show or hide stroke tails */
Expand All @@ -47,6 +50,10 @@ export class PreferencesStore {
this.autoMicOn = isOn;
};

public updateCursorNameOn = (isOn: boolean): void => {
this.cursorNameOn = isOn;
};

public updateCameraId = (cameraId: string): void => {
this.cameraId = cameraId;
};
Expand Down

0 comments on commit cdffb42

Please sign in to comment.