From 5a9fec1f253e30b148ec64c2dd0f957c54065c52 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Tue, 29 Jun 2021 16:45:30 +0530 Subject: [PATCH] feature(ui) - assist wip --- frontend/app/api_client.js | 3 +- frontend/app/components/Assist/Assist.tsx | 22 +++++----- .../Assist/ChatWindow/ChatWindow.tsx | 27 ++++++++++--- .../AssistActions/AssistActions.tsx | 21 ++++++---- .../VideoContainer/VideoContainer.tsx | 40 +++++++++++++------ .../LiveSessionList/LiveSessionList.tsx | 29 ++++++++++---- frontend/app/components/Session/LivePlayer.js | 9 +++-- .../components/Session_/PlayerBlockHeader.js | 4 +- frontend/app/duck/sessions.js | 25 ++++++++++-- .../MessageDistributor/MessageDistributor.ts | 4 +- frontend/app/types/session/session.js | 2 +- frontend/tailwind.config.js | 1 + frontend/tsconfig.json | 6 ++- 13 files changed, 135 insertions(+), 58 deletions(-) diff --git a/frontend/app/api_client.js b/frontend/app/api_client.js index bbba3a246..760123199 100644 --- a/frontend/app/api_client.js +++ b/frontend/app/api_client.js @@ -20,7 +20,8 @@ const siteIdRequiredPaths = [ '/rehydrations', '/sourcemaps', '/errors', - '/funnels' + '/funnels', + '/assist' ]; const noStoringFetchPathStarts = [ diff --git a/frontend/app/components/Assist/Assist.tsx b/frontend/app/components/Assist/Assist.tsx index 0140fcdd0..ced44fe9d 100644 --- a/frontend/app/components/Assist/Assist.tsx +++ b/frontend/app/components/Assist/Assist.tsx @@ -18,32 +18,32 @@ function Assist({ session, jwt }) { initPlayer(session, jwt); return () => cleanPlayer() }, [ session.sessionId ]); + useEffect(() => { if (screeRef.current) { attachPlayer(findDOMNode(screeRef.current)); - } }, [ ]) + return ( -
-
+ {/*
+ /> */} - {/* */}
) } export default connect(state => ({ - session: { // Testing mock. Should be retrieved from redux - startedAt: 1624314191394, - live: true, - sessionId: "4870254843916045", - }, + // session: { // Testing mock. Should be retrieved from redux + // // startedAt: 1624314191394, + // live: true, + // // sessionId: "4870254843916045", + // }, jwt: state.get('jwt'), }))(Assist); diff --git a/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx b/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx index e6bcc001a..1444dd3ba 100644 --- a/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx +++ b/frontend/app/components/Assist/ChatWindow/ChatWindow.tsx @@ -1,8 +1,8 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { IconButton } from 'UI'; import VideoContainer from '../components/VideoContainer'; -// import stl from './chatWindow.css'; - +import stl from './chatWindow.css'; +import { callPeer } from 'App/player'; interface Props { call: (oStream: MediaStream, cb: (iStream: MediaStream)=>void)=>void @@ -12,7 +12,12 @@ function ChatWindow({ call }: Props) { const [ inputStream, setInputStream ] = useState(null); const [ outputStream, setOutputStream ] = useState(null); - const onCallClick = () => { + useEffect(() => { + startOutputStream() + callPeer() + }, []) + + const startOutputStream = () => { navigator.mediaDevices.getUserMedia({video:true, audio:true}) .then(oStream => { setOutputStream(oStream); @@ -21,15 +26,25 @@ function ChatWindow({ call }: Props) { }) .catch(console.log) // TODO: handle error in ui } + + // const onCallClick = () => { + // navigator.mediaDevices.getUserMedia({video:true, audio:true}) + // .then(oStream => { + // setOutputStream(oStream); + // call(oStream, setInputStream); // Returns false when unable to connect. + // // TODO: handle calling state + // }) + // .catch(console.log) // TODO: handle error in ui + // } return (
-
+ {/*
-
+
*/}
) diff --git a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx index 6b2b89279..b56236f9c 100644 --- a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx +++ b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx @@ -1,24 +1,31 @@ import React from 'react' import { Button, Icon } from 'UI' +import { connect } from 'react-redux' import cn from 'classnames' +import { callPeer } from 'App/player'; +import { toggleChatWindow } from 'Duck/sessions'; // import stl from './AassistActions.css' interface Props { - isLive: false; + isLive: false; + toggleChatWindow: (state) => void } -function AssistActions({ }: Props) { +function AssistActions({ toggleChatWindow }: Props) { return (
-
+
toggleChatWindow(true)} + >
- - Request Control -
+ + Request Control +
) } -export default AssistActions +export default connect(null, { toggleChatWindow })(AssistActions) diff --git a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx index b03702fe4..33e207b14 100644 --- a/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx +++ b/frontend/app/components/Assist/components/VideoContainer/VideoContainer.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef } from 'react' +import React, { useState, useEffect, useRef } from 'react' import { Button, Icon } from 'UI' interface Props { @@ -6,24 +6,40 @@ interface Props { muted?: boolean } -function VideoContainer({ stream, muted = false }: Props) { +function VideoContainer({ stream, muted = false }: Props) { + const [muteAudio, setMuteAudio] = useState(false) + const [muteVideo, setMuteVideo] = useState(false) const ref = useRef(null); + useEffect(() => { if (ref.current) { ref.current.srcObject = stream; } }, [ ref.current, stream ]) - return ( -
-
-