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(region): set region when in room #802

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions web/flat-web/src/components/Whiteboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ import ToolBox from "@netless/tool-box";
import ZoomController from "@netless/zoom-controller";
import classNames from "classnames";
import { observer } from "mobx-react-lite";
import React, { useCallback } from "react";
import React, { useCallback, useEffect } from "react";
import { RoomPhase } from "white-web-sdk";
import { Region } from "flat-components";
import pagesSVG from "../assets/image/pages.svg";
import { ConfigStore } from "../stores/ConfigStore";
import { WhiteboardStore } from "../stores/WhiteboardStore";
import { isSupportedImageType, onDropImage } from "../utils/dnd/image";
import "./Whiteboard.less";

export interface WhiteboardProps {
whiteboardStore: WhiteboardStore;
configStore: ConfigStore;
}

export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({ whiteboardStore }) {
export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({
whiteboardStore,
configStore,
}) {
const { room } = whiteboardStore;

useEffect(() => {
if (room) {
configStore.setRegion(room.region as Region);
}
}, [room, configStore]);

const bindWhiteboard = useCallback(
(ref: HTMLDivElement) => {
if (room) {
Expand Down
5 changes: 3 additions & 2 deletions web/flat-web/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from "../../components/ExitRoomConfirm";
import InviteButton from "../../components/InviteButton";
import { RealtimePanel } from "../../components/RealtimePanel";
import { GlobalStoreContext } from "../../components/StoreProvider";
import { ConfigStoreContext, GlobalStoreContext } from "../../components/StoreProvider";
import { TopBarRightBtn } from "../../components/TopBarRightBtn";
import { TopBarRoundBtn } from "../../components/TopBarRoundBtn";
import { Whiteboard } from "../../components/Whiteboard";
Expand Down Expand Up @@ -87,6 +87,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
const classRoomStore = useClassRoomStore(params.roomUUID, params.ownerUUID, recordingConfig);
const whiteboardStore = classRoomStore.whiteboardStore;
const globalStore = useContext(GlobalStoreContext);
const configStore = useContext(ConfigStoreContext);
const { confirm, ...exitConfirmModalProps } = useExitRoomConfirmModal(classRoomStore);

const [speakingJoiner, setSpeakingJoiner] = useState<User | undefined>(() =>
Expand Down Expand Up @@ -175,7 +176,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
right={renderTopBarRight()}
/>
<div className="realtime-content">
<Whiteboard whiteboardStore={whiteboardStore} />
<Whiteboard whiteboardStore={whiteboardStore} configStore={configStore} />
{renderRealtimePanel()}
</div>
<ExitRoomConfirm isCreator={classRoomStore.isCreator} {...exitConfirmModalProps} />
Expand Down
5 changes: 3 additions & 2 deletions web/flat-web/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { useComputed } from "../../utils/mobx";
import { RouteNameType, RouteParams } from "../../utils/routes";
import { CloudStorageButton } from "../../components/CloudStorageButton";
import { AgoraCloudRecordBackgroundConfigItem } from "../../apiMiddleware/flatServer/agora";
import { GlobalStoreContext } from "../../components/StoreProvider";
import { ConfigStoreContext, GlobalStoreContext } from "../../components/StoreProvider";
import { runtime } from "../../utils/runtime";
import { useTranslation } from "react-i18next";

Expand Down Expand Up @@ -68,6 +68,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
const classRoomStore = useClassRoomStore(params.roomUUID, params.ownerUUID, recordingConfig);
const whiteboardStore = classRoomStore.whiteboardStore;
const globalStore = useContext(GlobalStoreContext);
const configStore = useContext(ConfigStoreContext);
const { confirm, ...exitConfirmModalProps } = useExitRoomConfirmModal(classRoomStore);

const [isRealtimeSideOpen, openRealtimeSide] = useState(true);
Expand Down Expand Up @@ -130,7 +131,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
right={renderTopBarRight()}
/>
<div className="one-to-one-realtime-content">
<Whiteboard whiteboardStore={whiteboardStore} />
<Whiteboard whiteboardStore={whiteboardStore} configStore={configStore} />
{renderRealtimePanel()}
</div>
<ExitRoomConfirm isCreator={classRoomStore.isCreator} {...exitConfirmModalProps} />
Expand Down
5 changes: 3 additions & 2 deletions web/flat-web/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { RouteNameType, RouteParams } from "../../utils/routes";

import "./SmallClassPage.less";
import { CloudStorageButton } from "../../components/CloudStorageButton";
import { GlobalStoreContext } from "../../components/StoreProvider";
import { ConfigStoreContext, GlobalStoreContext } from "../../components/StoreProvider";
import { runtime } from "../../utils/runtime";
import { RtcChannelType } from "../../apiMiddleware/rtc/room";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -93,6 +93,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
);
const whiteboardStore = classRoomStore.whiteboardStore;
const globalStore = useContext(GlobalStoreContext);
const configStore = useContext(ConfigStoreContext);
const { confirm, ...exitConfirmModalProps } = useExitRoomConfirmModal(classRoomStore);

const { room, phase } = whiteboardStore;
Expand Down Expand Up @@ -152,7 +153,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
/>
{renderAvatars()}
<div className="realtime-content">
<Whiteboard whiteboardStore={whiteboardStore} />
<Whiteboard whiteboardStore={whiteboardStore} configStore={configStore} />
{renderRealtimePanel()}
</div>
<ExitRoomConfirm isCreator={classRoomStore.isCreator} {...exitConfirmModalProps} />
Expand Down