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(whiteboard): window-manager not mount when whiteboard was connected #1034

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
10 changes: 2 additions & 8 deletions desktop/renderer-app/src/components/Whiteboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import { WindowManager } from "@netless/window-manager";
import { WhiteboardStore } from "../stores/whiteboard-store";
import { isSupportedImageType, onDropImage } from "../utils/dnd/image";
import { ScenesController } from "flat-components";
import { useIsUnMounted } from "../utils/hooks/lifecycle";

export interface WhiteboardProps {
whiteboardStore: WhiteboardStore;
}

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

const [whiteboardEl, setWhiteboardEl] = useState<HTMLElement | null>(null);
const [collectorEl, setCollectorEl] = useState<HTMLElement | null>(null);
Expand All @@ -41,12 +39,8 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({ whiteb
},
chessboard: false,
});
if (isUnMountedRef.current) {
whiteboardStore.destroyWindowManager();
} else {
whiteboardStore.onMainViewModeChange();
whiteboardStore.onWindowManagerBoxStateChange();
}
whiteboardStore.onMainViewModeChange();
whiteboardStore.onWindowManagerBoxStateChange();
}
};

Expand Down
6 changes: 5 additions & 1 deletion desktop/renderer-app/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

// control whiteboard writable
useEffect(() => {
Expand Down Expand Up @@ -171,7 +172,9 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
whiteboardStore.phase === RoomPhase.Disconnecting ||
whiteboardStore.phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

function handleShareScreen(): void {
Expand All @@ -184,6 +187,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()

return (
<div className="realtime-box">
{loadingPageRef.current && <LoadingPage />}
<TopBar
isMac={runtime.isMac}
left={renderTopBarLeft()}
Expand Down
6 changes: 5 additions & 1 deletion desktop/renderer-app/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

const { t } = useTranslation();

Expand Down Expand Up @@ -129,7 +130,9 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
whiteboardStore.phase === RoomPhase.Disconnecting ||
whiteboardStore.phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

function handleShareScreen(): void {
Expand All @@ -142,6 +145,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()

return (
<div className="one-to-one-realtime-box">
{loadingPageRef.current && <LoadingPage />}
<TopBar
isMac={runtime.isMac}
left={renderTopBarLeft()}
Expand Down
6 changes: 5 additions & 1 deletion desktop/renderer-app/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

const { t } = useTranslation();

Expand Down Expand Up @@ -150,7 +151,9 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
phase === RoomPhase.Disconnecting ||
phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

function handleShareScreen(): void {
Expand All @@ -163,6 +166,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP

return (
<div className="realtime-box">
{loadingPageRef.current && <LoadingPage />}
<TopBar
isMac={runtime.isMac}
left={renderTopBarLeft()}
Expand Down
11 changes: 3 additions & 8 deletions web/flat-web/src/components/Whiteboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import React, { useCallback, useEffect, useState } from "react";
import { WhiteboardStore } from "../stores/whiteboard-store";
import { isSupportedImageType, onDropImage } from "../utils/dnd/image";
import { ScenesController } from "../../../../packages/flat-components/src";
import { useIsUnMounted } from "../utils/hooks/lifecycle";

export interface WhiteboardProps {
whiteboardStore: WhiteboardStore;
}

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

const [whiteboardEl, setWhiteboardEl] = useState<HTMLElement | null>(null);
const [collectorEl, setCollectorEl] = useState<HTMLElement | null>(null);
Expand All @@ -41,12 +39,9 @@ export const Whiteboard = observer<WhiteboardProps>(function Whiteboard({ whiteb
},
chessboard: false,
});
if (isUnMountedRef.current) {
whiteboardStore.destroyWindowManager();
} else {
whiteboardStore.onMainViewModeChange();
whiteboardStore.onWindowManagerBoxStateChange();
}

whiteboardStore.onMainViewModeChange();
whiteboardStore.onWindowManagerBoxStateChange();
}
};

Expand Down
6 changes: 5 additions & 1 deletion web/flat-web/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

// control whiteboard writable
useEffect(() => {
Expand Down Expand Up @@ -169,11 +170,14 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
whiteboardStore.phase === RoomPhase.Disconnecting ||
whiteboardStore.phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

return (
<div className="realtime-container">
{loadingPageRef.current && <LoadingPage />}
<div className="realtime-box">
<TopBar
isMac={runtime.isMac}
Expand Down
10 changes: 7 additions & 3 deletions web/flat-web/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

const joiner = useComputed(() => {
if (classRoomStore.isCreator) {
Expand Down Expand Up @@ -122,11 +123,14 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
whiteboardStore.phase === RoomPhase.Disconnecting ||
whiteboardStore.phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

return (
<div className="one-to-one-realtime-container">
{loadingPageRef.current && <LoadingPage />}
<div className="one-to-one-realtime-box">
<TopBar
isMac={runtime.isMac}
Expand Down Expand Up @@ -259,8 +263,8 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
title="Vision control"
icon={
whiteboardStore.isBroadcasterMode === undefined
? "follow-active"
: "follow"
? "follow"
: "follow-active"
}
onClick={toggleRoomVisionController}
/>
Expand Down
6 changes: 5 additions & 1 deletion web/flat-web/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
const [isRealtimeSideOpen, openRealtimeSide] = useState(true);

const updateLayoutTimeoutRef = useRef(NaN);
const loadingPageRef = useRef(false);

// control whiteboard writable
useEffect(() => {
Expand Down Expand Up @@ -144,7 +145,9 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
phase === RoomPhase.Disconnecting ||
phase === RoomPhase.Reconnecting
) {
return <LoadingPage />;
loadingPageRef.current = true;
} else {
loadingPageRef.current = false;
}

function handleShareScreen(): void {
Expand All @@ -153,6 +156,7 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP

return (
<div className="realtime-container">
{loadingPageRef.current && <LoadingPage />}
<div className="realtime-box">
<TopBar
isMac={runtime.isMac}
Expand Down