Skip to content
Snippets Groups Projects
Unverified Commit fa9d85d5 authored by Jean Brito's avatar Jean Brito Committed by GitHub
Browse files

Chore: Add RocketChatDesktop function to open video calls when using Electron (#26793)

parent 3c2679ba
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,12 @@ import { VideoConfManager, DirectCallParams, ProviderCapabilities, CallPreferenc
import VideoConfBlockModal from '../views/room/contextualBar/VideoConference/VideoConfBlockModal';
import VideoConfPopups from '../views/room/contextualBar/VideoConference/VideoConfPopups';
type WindowMaybeDesktop = typeof window & {
RocketChatDesktop?: {
openInternalVideoChatWindow?: (url: string, options: undefined) => void;
};
};
const VideoConfContextProvider = ({ children }: { children: ReactNode }): ReactElement => {
const [outgoing, setOutgoing] = useState<VideoConfPopupPayload | undefined>();
const setModal = useSetModal();
......@@ -15,16 +21,21 @@ const VideoConfContextProvider = ({ children }: { children: ReactNode }): ReactE
useEffect(
() =>
VideoConfManager.on('call/join', (props) => {
const open = (): void => {
const popup = window.open(props.url);
const windowMaybeDesktop = window as WindowMaybeDesktop;
if (windowMaybeDesktop.RocketChatDesktop?.openInternalVideoChatWindow) {
windowMaybeDesktop.RocketChatDesktop.openInternalVideoChatWindow(props.url, undefined);
} else {
const open = (): void => {
const popup = window.open(props.url);
if (popup !== null) {
return;
}
if (popup !== null) {
return;
}
setModal(<VideoConfBlockModal onClose={(): void => setModal(null)} onConfirm={open} />);
};
open();
setModal(<VideoConfBlockModal onClose={(): void => setModal(null)} onConfirm={open} />);
};
open();
}
}),
[setModal],
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment