
* feat: [#21] stand up file sharing controls UI * feat: [#21] implement basic file transfer * feat: [#21] save transferred file * feat: [#21] transfer file via WebTorrent * fix: use external streamsaver assets * feat: [#21] initiate download by receiver click * fix: enable re-downloading of shared files * feat: [#21] implement sharing of multiple files * chore: enable offline development * feat: cache torrents in IndexedDB * feat: show alert when download is aborted * feat: [#21] clean up torrent data when principal offerer rescinds it * feat: clean up cached torrents on page unload * feat: show file transfer progress * fix: download files sequentially * feat: clean up file transfers when leaving the room * feat: clean up broken downloads upon leaving the page * fix: allow download animation to complete * feat: show tooltip for download button * feat: make file transfers work in browser private modes * feat: disable file share controls while creating offer
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import Box from '@mui/material/Box'
|
|
import ScreenShare from '@mui/icons-material/ScreenShare'
|
|
import StopScreenShare from '@mui/icons-material/StopScreenShare'
|
|
import Fab from '@mui/material/Fab'
|
|
import Tooltip from '@mui/material/Tooltip'
|
|
|
|
import { PeerRoom } from 'services/PeerRoom/PeerRoom'
|
|
|
|
import { useRoomScreenShare } from './useRoomScreenShare'
|
|
|
|
export interface RoomFileUploadControlsProps {
|
|
peerRoom: PeerRoom
|
|
}
|
|
|
|
export function RoomScreenShareControls({
|
|
peerRoom,
|
|
}: RoomFileUploadControlsProps) {
|
|
const { isSharingScreen, handleScreenShareStart, handleScreenShareStop } =
|
|
useRoomScreenShare({
|
|
peerRoom,
|
|
})
|
|
|
|
const handleToggleScreenShareButtonClick = () => {
|
|
if (isSharingScreen) {
|
|
handleScreenShareStop()
|
|
} else {
|
|
handleScreenShareStart()
|
|
}
|
|
}
|
|
|
|
if (!window.navigator?.mediaDevices?.getDisplayMedia) {
|
|
return <></>
|
|
}
|
|
|
|
return (
|
|
<Box
|
|
sx={{
|
|
alignItems: 'center',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
justifyContent: 'center',
|
|
px: 1,
|
|
}}
|
|
>
|
|
<Tooltip
|
|
title={
|
|
isSharingScreen ? 'Stop sharing screen' : 'Share screen with room'
|
|
}
|
|
>
|
|
<Fab
|
|
color={isSharingScreen ? 'error' : 'success'}
|
|
aria-label="share screen"
|
|
onClick={handleToggleScreenShareButtonClick}
|
|
>
|
|
{isSharingScreen ? <StopScreenShare /> : <ScreenShare />}
|
|
</Fab>
|
|
</Tooltip>
|
|
</Box>
|
|
)
|
|
}
|