testing connecting with footer controls and working

This commit is contained in:
talksik
2022-07-05 09:52:33 -05:00
parent b84a5f0fa9
commit 98530e1578
4 changed files with 48 additions and 28 deletions
+2 -2
View File
@@ -42,8 +42,8 @@
[ [
"@electron-forge/plugin-webpack", "@electron-forge/plugin-webpack",
{ {
"port": "4005", "port": "4000",
"loggerPort": "9005", "loggerPort": "9000",
"mainConfig": "./webpack.main.config.js", "mainConfig": "./webpack.main.config.js",
"devContentSecurityPolicy": "default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;", "devContentSecurityPolicy": "default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;",
"renderer": { "renderer": {
@@ -23,15 +23,14 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
useEffect(() => { useEffect(() => {
// on load of this, if we already have jwt tokens in store, // on load of this, if we already have jwt tokens in store,
// then try using them with auth check // then try using them with auth check
window.electronAPI.store.get(STORE_ITEMS.AUTH_SESSION_JWT).then((jwtToken: string) => { // window.electronAPI.store.get(STORE_ITEMS.AUTH_SESSION_JWT).then((jwtToken: string) => {
if (jwtToken) { // if (jwtToken) {
setJwtToken(jwtToken); // setJwtToken(jwtToken);
// console.log('retrieved jwtToken from storage', jwtToken);
console.log('retrieved jwtToken from storage', jwtToken); // } else {
} else { // console.log('no jwt token in store');
console.log('no jwt token in store'); // }
} // });
});
}, []); }, []);
// todo: check this in intervals repeatedly // todo: check this in intervals repeatedly
+24 -6
View File
@@ -3,6 +3,7 @@ import {
AvatarGroup, AvatarGroup,
Box, Box,
Button, Button,
CircularProgress,
Container, Container,
Dialog, Dialog,
Divider, Divider,
@@ -30,10 +31,10 @@ import {
FiZap, FiZap,
FiZapOff, FiZapOff,
} from 'react-icons/fi'; } from 'react-icons/fi';
import { MasterConversation, RoomMap } from '../util/types';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { ConversationUserMember } from '@nirvana/core/models/conversation.model'; import { ConversationUserMember } from '@nirvana/core/models/conversation.model';
import { MasterConversation } from '../util/types';
import { SUPPORT_DISPLAY_NAME } from '../util/support'; import { SUPPORT_DISPLAY_NAME } from '../util/support';
import { blueGrey } from '@mui/material/colors'; import { blueGrey } from '@mui/material/colors';
import useAuth from '../providers/AuthProvider'; import useAuth from '../providers/AuthProvider';
@@ -266,6 +267,8 @@ function OverlayConversation({
conversationUserMembers={masterConversation.members} conversationUserMembers={masterConversation.members}
isConversationSelected={isSelected} isConversationSelected={isSelected}
tunedInUserIds={masterConversation.tunedInUsers} tunedInUserIds={masterConversation.tunedInUsers}
roomPeers={masterConversation.room}
localStreamToPeers={masterConversation.localStream}
/> />
{isSelected && ( {isSelected && (
@@ -314,10 +317,14 @@ function OverlayConversationAvatars({
conversationUserMembers, conversationUserMembers,
tunedInUserIds, tunedInUserIds,
isConversationSelected, isConversationSelected,
roomPeers,
localStreamToPeers,
}: { }: {
isConversationSelected: boolean; isConversationSelected: boolean;
tunedInUserIds: string[]; tunedInUserIds: string[];
conversationUserMembers: ConversationUserMember[]; conversationUserMembers: ConversationUserMember[];
roomPeers: RoomMap;
localStreamToPeers: MediaStream;
}) { }) {
const { user } = useAuth(); const { user } = useAuth();
@@ -358,6 +365,10 @@ function OverlayConversationAvatars({
isTunedIn={tunedInUserIds?.includes(conversationUserMember._id.toString())} isTunedIn={tunedInUserIds?.includes(conversationUserMember._id.toString())}
isConversationSelected={isConversationSelected} isConversationSelected={isConversationSelected}
conversationUserMember={conversationUserMember} conversationUserMember={conversationUserMember}
isConnecting={
(roomPeers && roomPeers[conversationUserMember._id.toString()]?.isConnecting) ?? false
}
localStreamToPeers={localStreamToPeers}
/> />
))} ))}
</AvatarGroup> </AvatarGroup>
@@ -368,23 +379,30 @@ function OverlayConversationAvatar({
conversationUserMember, conversationUserMember,
isTunedIn, isTunedIn,
isConversationSelected, isConversationSelected,
isConnecting,
localStreamToPeers,
}: { }: {
conversationUserMember: ConversationUserMember; conversationUserMember: ConversationUserMember;
isTunedIn: boolean; isTunedIn: boolean;
isConversationSelected: boolean; // if user is connecting or just have this conversation selected isConversationSelected: boolean; // if user is connecting or just have this conversation selected
isConnecting: boolean; // if we are calling or receiving call from this person and still connecting
localStreamToPeers: MediaStream; // the local stream that is casted to each peer
}) { }) {
const { userLocalStream } = useConversations();
const { user } = useAuth(); const { user } = useAuth();
const localVideoRef = useRef<HTMLVideoElement>(null); const localVideoRef = useRef<HTMLVideoElement>(null);
useEffect(() => { useEffect(() => {
if (localVideoRef?.current && userLocalStream) { if (localVideoRef?.current && localStreamToPeers) {
localVideoRef.current.srcObject = userLocalStream; localVideoRef.current.srcObject = localStreamToPeers;
} }
}, [localVideoRef, userLocalStream]); }, [localVideoRef, localStreamToPeers]);
if (conversationUserMember._id.toString() === user._id.toString() && userLocalStream) { if (isConnecting) {
return <CircularProgress />;
}
if (conversationUserMember._id.toString() === user._id.toString() && localStreamToPeers) {
return ( return (
<Box <Box
height={40} height={40}
+14 -11
View File
@@ -12,23 +12,26 @@ export type MasterConversation = Conversation & {
// if action is take, normal ordering should take place with database upserts // if action is take, normal ordering should take place with database upserts
temporaryOverrideSort?: boolean; temporaryOverrideSort?: boolean;
room?: { room?: RoomMap;
[userId: string]: { // the local stream that we are casting to each peer
peer: Peer;
//the remote stream of this peer
stream?: MediaStream;
// calling happening whether it is a newbie or master
isConnecting?: boolean;
};
};
localStream?: MediaStream; localStream?: MediaStream;
// all of audio clips, links, media, etc. // all of audio clips, links, media, etc.
content?: ContentBlock[]; content?: ContentBlock[];
}; };
export type RoomMap = {
[userId: string]: {
peer: Peer;
// the remote stream of this peer
stream?: MediaStream;
// calling happening whether it is a newbie or master
isConnecting?: boolean;
};
};
export type ConversationMap = { export type ConversationMap = {
[conversationId: string]: MasterConversation; [conversationId: string]: MasterConversation;
}; };