From 885f0039d8a0633f5bfb06c5cd24b6687ee6c51f Mon Sep 17 00:00:00 2001 From: talksik Date: Thu, 2 Jun 2022 03:37:36 -0500 Subject: [PATCH] cleanup --- packages/desktop/package.json | 4 +- .../src/providers/CommunicationsProvider.tsx | 58 +------ packages/desktop/twilio_secret_key | 0 packages/firebase/functions/tsconfig.json | 5 +- yarn.lock | 144 ++++++------------ 5 files changed, 59 insertions(+), 152 deletions(-) create mode 100644 packages/desktop/twilio_secret_key diff --git a/packages/desktop/package.json b/packages/desktop/package.json index 47894d4..141b915 100644 --- a/packages/desktop/package.json +++ b/packages/desktop/package.json @@ -95,6 +95,8 @@ "typescript": "~4.5.4" }, "dependencies": { + "@daily-co/daily-js": "^0.26.0", + "@daily-co/daily-react-hooks": "^0.2.3", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", "@getstation/electron-google-oauth2": "^2.1.0", @@ -110,7 +112,7 @@ "react-error-boundary": "^3.1.4", "react-icons": "^4.3.1", "react-use": "^17.4.0", - "twilio-video": "^2.21.1", + "recoil": "^0.7.3-alpha.2", "use-immer": "^0.7.0" } } diff --git a/packages/desktop/src/providers/CommunicationsProvider.tsx b/packages/desktop/src/providers/CommunicationsProvider.tsx index 6e9736b..5e44ed0 100644 --- a/packages/desktop/src/providers/CommunicationsProvider.tsx +++ b/packages/desktop/src/providers/CommunicationsProvider.tsx @@ -1,6 +1,5 @@ /* eslint-disable jsx-a11y/media-has-caption */ /* eslint-disable react/jsx-no-comment-textnodes */ -import { ConnectOptions, Room, connect } from 'twilio-video'; import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'; import { useMediaDevices, useMount } from 'react-use'; @@ -58,13 +57,9 @@ interface ICommunicationsContext { userLocalStream?: MediaStream; userDeviceSelections?: DeviceSelections; - - room: Room | null; } -const CommunicationsContext = React.createContext({ - room: null, -}); +const CommunicationsContext = React.createContext({}); // todo save the selected devices in localstorage export function CommunicationsProvider({ children }: { children: React.ReactNode }) { @@ -75,61 +70,18 @@ export function CommunicationsProvider({ children }: { children: React.ReactNode const devices = useUserDevices(); - const [room, setRoom] = useState(null); const localAudioRef = useRef(null); - const getAuthToken = useCallback(async () => { - const result = await getTwilioAccessToken(); - const data = result.data as TwilioAccessToken; - - enqueueSnackbar('got token data'); - - return data.token; - }, [enqueueSnackbar]); - const connectToRoom = useCallback( async (conversationId: string) => { try { - const token = await getAuthToken(); - - connect(token, { - name: conversationId, - audio: true, - }).then( - (room) => { - enqueueSnackbar('joined room', { variant: 'success' }); - - // Log your Client's LocalParticipant in the Room - const localParticipant = room.localParticipant; - console.log(`Connected to the Room as LocalParticipant "${localParticipant.identity}"`); - - // Log any Participants already connected to the Room - room.participants.forEach((participant) => { - console.log(`Participant "${participant.identity}" is connected to the Room`); - }); - - // Log new Participants as they connect to the Room - room.once('participantConnected', (participant) => { - console.log(`Participant "${participant.identity}" has connected to the Room`); - }); - - // Log Participants as they disconnect from the Room - room.once('participantDisconnected', (participant) => { - console.log(`Participant "${participant.identity}" has disconnected from the Room`); - }); - - setRoom(room); - }, - (error) => { - console.error(`Unable to connect to Room: ${error.message}`); - }, - ); + console.log('hey'); } catch (error) { console.error(error); enqueueSnackbar('something went wrong trying to set up calls', { variant: 'error' }); } }, - [getAuthToken, enqueueSnackbar, setRoom], + [enqueueSnackbar], ); // every time conversation is selected @@ -140,8 +92,6 @@ export function CommunicationsProvider({ children }: { children: React.ReactNode connectToRoom(selectedConversation.id); } else { // leave room - - setRoom(null); } }, [selectedConversation?.id, connectToRoom]); @@ -161,7 +111,7 @@ export function CommunicationsProvider({ children }: { children: React.ReactNode }); return ( - +