Skip to content

Commit

Permalink
refactor: rm video
Browse files Browse the repository at this point in the history
  • Loading branch information
arn4b committed Sep 14, 2023
1 parent 1f9a753 commit a473a53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
15 changes: 9 additions & 6 deletions packages/restapi/src/lib/spaceV2/acceptInvite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* @file acceptInvite
* This file defines functions related to accepting invites
* and managing connections within the SpaceV2 class.
* It includes the `acceptInvite` function,
* which handles incoming invitations and manages peer connections,
* as well as related utility functions.
*/

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import * as Peer from 'simple-peer';
Expand Down Expand Up @@ -121,12 +130,6 @@ export async function acceptInvite(
});

peerConnection.on('connect', () => {
peerConnection.send(
JSON.stringify({
type: 'isVideoOn',
value: this.data.local.video,
})
);
peerConnection.send(
JSON.stringify({
type: 'isAudioOn',
Expand Down
15 changes: 2 additions & 13 deletions packages/restapi/src/lib/spaceV2/inviteToJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ export async function inviteToJoin(
peerConnection.send(
`initial message from ${senderAddress}`
);
peerConnection.send(
JSON.stringify({
type: 'isVideoOn',
value: this.data.local.video,
})
);
peerConnection.send(
JSON.stringify({
type: 'isAudioOn',
Expand All @@ -146,7 +140,7 @@ export async function inviteToJoin(
if (isJSON(data)) {
const parsedData = JSON.parse(data);

if (parsedData.type === 'isVideoOn' || parsedData.type === 'isAudioOn') {
if (parsedData.type === 'isAudioOn') {
console.log(`IS ${parsedData.type.toUpperCase()}`, parsedData.value);

this.setSpaceV2Data((oldData) => {
Expand All @@ -167,12 +161,7 @@ export async function inviteToJoin(

// If the peer is found in either array, update the property
if (arrayToUpdate) {
if (parsedData.type === 'isVideoOn') {
arrayToUpdate[indexInIncoming !== -1 ? indexInIncoming : indexInPending].video = parsedData.value;
}
if (parsedData.type === 'isAudioOn') {
arrayToUpdate[indexInIncoming !== -1 ? indexInIncoming : indexInPending].audio = parsedData.value;
}
arrayToUpdate[indexInIncoming !== -1 ? indexInIncoming : indexInPending].audio = parsedData.value;
}
});
});
Expand Down

0 comments on commit a473a53

Please sign in to comment.