From ceb9365bddd0a088ff9feebdba41e0cae61f3ba7 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 29 Jan 2025 11:36:07 -0800 Subject: [PATCH] removing temp files --- app/client/mobile/src/bucal/Calling.styled.ts | 83 ----- app/client/mobile/src/bucal/Calling.tsx | 170 ---------- .../mobile/src/bucal/useCalling.hook.ts | 303 ------------------ app/client/mobile/src/db.path | 1 - app/client/mobile/src/session/sbu | 213 ------------ app/client/mobile/src/todo.txt | 73 ----- 6 files changed, 843 deletions(-) delete mode 100644 app/client/mobile/src/bucal/Calling.styled.ts delete mode 100644 app/client/mobile/src/bucal/Calling.tsx delete mode 100644 app/client/mobile/src/bucal/useCalling.hook.ts delete mode 100644 app/client/mobile/src/db.path delete mode 100644 app/client/mobile/src/session/sbu delete mode 100644 app/client/mobile/src/todo.txt diff --git a/app/client/mobile/src/bucal/Calling.styled.ts b/app/client/mobile/src/bucal/Calling.styled.ts deleted file mode 100644 index 1666668d..00000000 --- a/app/client/mobile/src/bucal/Calling.styled.ts +++ /dev/null @@ -1,83 +0,0 @@ -import {StyleSheet} from 'react-native'; -import { Colors } from '../constants/Colors'; - -export const styles = StyleSheet.create({ - blur: { - position: 'absolute', - top: 0, - left: 0, - width: '100%', - height: '100%', - }, - active: { - display: 'flex', - width: '100%', - height: '100%', - position: 'absolute', - alignItems: 'center', - justifyContent: 'center', - backgroundColor: 'rgb(64,64,64)', - }, - inactive: { - display: 'none', - width: '100%', - height: '100%', - position: 'absolute', - alignItems: 'center', - justifyContent: 'center', - backgroundColor: 'rgb(64,64,64)', - }, - container: { - width: '100%', - height: '100%', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - }, - call: { - width: '100%', - height: '100%', - display: 'flex', - }, - image: { - width: '100%', - height: '100%', - borderRadius: 8, - }, - frame: { - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - borderRadius: 8, - overflow: 'hidden', - padding: 2, - position: 'absolute', - }, - closeIcon: { - borderRadius: 8, - }, - name: { - fontSize: 28, - minWidth: '50%', - color: '#aaaaaa', - paddingLeft: 16, - width: '100%', - textAlign: 'center', - }, - overlap: { - display: 'flex', - flexDirection: 'row', - position: 'absolute', - alignItems: 'center', - justifyContent: 'center', - paddingBottom: 8, - paddingTop: 8, - gap: 32, - }, - local: { - position: 'absolute', - right: 16, - width: '20%', - height: '20%', - }, -}); diff --git a/app/client/mobile/src/bucal/Calling.tsx b/app/client/mobile/src/bucal/Calling.tsx deleted file mode 100644 index 937eb2bb..00000000 --- a/app/client/mobile/src/bucal/Calling.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { useWindowDimensions, Image, SafeAreaView, Modal, ScrollView, View } from 'react-native'; -import { Surface, Icon, Divider, Button, IconButton, Text, TextInput} from 'react-native-paper'; -import {styles} from './Calling.styled'; -import {useCalling} from './useCalling.hook'; -import {BlurView} from '@react-native-community/blur'; -import { Confirm } from '../confirm/Confirm'; -import { ActivityIndicator } from 'react-native-paper'; -import FastImage from 'react-native-fast-image' -import LinearGradient from 'react-native-linear-gradient'; -import { Colors } from '../constants/Colors'; -import { RTCView } from 'react-native-webrtc'; - -export function Calling({ callCard }: { callCard: string }) { - const { state, actions } = useCalling(); - const [alert, setAlert] = useState(false); - const [connecting, setConnecting] = useState(false); - const [ending, setEnding] = useState(false); - const {height, width} = useWindowDimensions(); - const [applyingVideo, setApplyingVideo] = useState(false); - const [applyingAudio, setApplyingAudio] = useState(false); - - const toggleVideo = async () => { - if (!applyingVideo) { - setApplyingVideo(true); - try { - if (state.video && state.videoEnabled) { - await actions.disableVideo(); - } else if (state.video && !state.videoEnabled) { - await actions.enableVideo(); - } - } catch (err) { - console.log(err); - setAlert(true); - } - setApplyingVideo(false); - } - } - - const toggleAudio = async () => { - if (!applyingAudio) { - setApplyingAudio(true); - try { - if (state.audio && state.audioEnabled) { - await actions.disableAudio(); - } else if (state.audio && !state.audioEnabled) { - await actions.enableAudio(); - } - } catch (err) { - console.log(err); - setAlert(true); - } - setApplyingAudio(false); - } - } - - const end = async () => { - if (!ending) { - setEnding(true); - try { - await actions.end(); - } catch (err) { - console.log(err); - setAlert(true); - } - setEnding(false); - } - } - - const call = async (cardId: string) => { - if (!connecting) { - setConnecting(true); - try { - await actions.call(cardId); - } catch (err) { - console.log(err); - setAlert(true); - } - setConnecting(false); - } - } - - const alertParams = { - title: state.strings.operationFailed, - prompt: state.strings.tryAgain, - cancel: { - label: state.strings.close, - action: () => { - setAlert(false); - }, - }, - }; - - useEffect(() => { - const { cardId } = callCard; - if (cardId) { - call(cardId); - } - }, [callCard]); - - const overlap = (width + 128) > height; - const frameWidth = width > height ? height : width - 16; - const frameHeight = frameWidth; - const frameOffset = (height - frameHeight) / 8; - return ( - 0 || alert) ? styles.active : styles.inactive}> - - { connecting && !state.calling && ( - - )} - { state.calling && ( - - - { state.loaded && ( - - - - )} - { state.loaded && ( - - - - )} - { state.loaded && ( - - )} - { state.loaded && ( - - )} - - )} - { state.calling && state.loaded && ( - - { state.calling.name && ( - { state.calling.name } - )} - { !state.calling.name && ( - { `${state.calling.handle}/${state.calling.node}` } - )} - - )} - { state.calling && state.loaded && ( - - - - - - - - )} - { state.calling && state.loaded && state.local && ( - - )} - - - - ); -} - diff --git a/app/client/mobile/src/bucal/useCalling.hook.ts b/app/client/mobile/src/bucal/useCalling.hook.ts deleted file mode 100644 index 23ea717b..00000000 --- a/app/client/mobile/src/bucal/useCalling.hook.ts +++ /dev/null @@ -1,303 +0,0 @@ -import { useState, useContext, useEffect, useRef } from 'react' -import { DisplayContext } from '../context/DisplayContext'; -import { AppContext } from '../context/AppContext' -import { ContextType } from '../context/ContextType' -import { Link, type Card } from 'databag-client-sdk'; - -import { - ScreenCapturePickerView, - RTCPeerConnection, - RTCIceCandidate, - RTCSessionDescription, - RTCView, - MediaStream, - MediaStreamTrack, - mediaDevices, - registerGlobals -} from 'react-native-webrtc'; - -export function useCalling() { - const app = useContext(AppContext) as ContextType; - const display = useContext(DisplayContext) as ContextType; - const call = useRef(null as { policy: string, peer: RTCPeerConnection, link: Link, candidates: RTCIceCandidate[] } | null); - const stream = useRef(null); - const [state, setState] = useState({ - strings: {}, - ringing: [], - calls: [], - cards: [], - calling: null as null | Card, - failed: false, - loaded: false, - panelOffset: 0, - local: null, - audio: null, - audioEnabled: false, - video: null, - videoEnabled: false, - videoAdded: false, - }) - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const updateState = (value: any) => { - setState((s) => ({ ...s, ...value })) - } - - useEffect(() => { - const calls = state.ringing - .map(ring => ({ callId: ring.callId, card: state.cards.find(card => ring.cardId === card.cardId) }) ) - .filter(ring => (ring.card && !ring.card.blocked)); - updateState({ calls }); - }, [state.ringing, state.cards]); - - useEffect(() => { - const { strings } = display.state; - updateState({ strings }); - }, [display.state]); - - const constraints = { - mandatory: { - OfferToReceiveAudio: true, - OfferToReceiveVideo: false, - VoiceActivityDetection: true - } - }; - - const linkStatus = async (status: string) => { - if (call.current) { - const { policy, peer, link } = call.current; - if (status === 'connected') { - try { - stream.current = await mediaDevices.getUserMedia({ - audio: true, - video: { - frameRate: 30, - facingMode: 'user' - } - }); - const audio = stream.current.getTracks().find(track => track.kind === 'audio'); - const video = stream.current.getTracks().find(track => track.kind === 'video'); - if (audio) { - audio.enabled = true; - peer.addTrack(audio, stream.current); - } - if (video) { - video.enabled = false; - } - updateState({ audio, video, audioAdded: true, audioEnabled: true, videoAdded: false, videoEnabled: false }); - } catch (err) { - console.log(err); - updateState({ failed: true }); - } - } else if (status === 'closed') { - try { - peer.close(); - link.close(); - } catch (err) { - console.log(err); - } - call.current = null; - stream.current = null; - updateState({ calling: null, failed: false, audio: null, video: null }); - } - } - } - - const linkMessage = async (message: any) => { - if (call.current) { - const { peer, link, candidates, policy } = call.current; - try { - if (message.description) { - if (message.description.type === 'offer' && peer.signalingState !== 'stable') { - if (policy === 'polite') { - const rollback = new RTCSessionDescription({ type: 'rollback' }); - await peer.setLocalDescription(rollback); - } else { - return; - } - } - const offer = new RTCSessionDescription(message.description); - await peer.setRemoteDescription(offer); - if (message.description.type === 'offer') { - const description = await peer.createAnswer(); - await peer.setLocalDescription(description); - link.sendMessage({ description }); - } - - for (const candidate of candidates) { - await peer.addIceCandidate(candidate); - }; - candidates.length = 0; - } else if (message.candidate) { - const candidate = new RTCIceCandidate(message.candidate); - if (peer.remoteDescription == null) { - candidates.push(candidate); - } else { - await peer.addIceCandidate(candidate); - } - } - } catch (err) { - console.log(err); - updateState({ failed: true }); - } - } - } - - const peerCandidate = async (candidate) => { - if (call.current && candidate) { - const { link } = call.current; - await link.sendMessage({ candidate }); - } - } - - const peerNegotiate = async () => { - if (call.current) { - const { peer, link } = call.current; - const description = await peer.createOffer(constraints); - await peer.setLocalDescription(description); - await link.sendMessage({ description }); - } - } - - const transmit = (ice: { urls: string; username: string; credential: string }[]) => { - const peerConnection = new RTCPeerConnection({ iceServers: ice }); - peerConnection.addEventListener( 'connectionstatechange', event => { - console.log("CONNECTION STATE", event); - }); - peerConnection.addEventListener( 'icecandidate', event => { - peerCandidate(event.candidate); - }); - peerConnection.addEventListener( 'icecandidateerror', event => { - console.log("ICE ERROR"); - }); - peerConnection.addEventListener( 'iceconnectionstatechange', event => { - console.log("ICE STATE CHANGE", event); - }); - peerConnection.addEventListener( 'negotiationneeded', event => { - peerNegotiate(); - }); - peerConnection.addEventListener( 'signalingstatechange', event => { - console.log("ICE SIGNALING", event); - }); - peerConnection.addEventListener( 'track', event => { - //stream.current.addTrack(event.track, stream.current); - }); - return peerConnection; - } - - useEffect(() => { - if (app.state.session) { - const setRinging = (ringing: { cardId: string, callId: string }[]) => { - updateState({ ringing }); - } - const setContacts = (cards: Card[]) => { - updateState({ cards }); - } - const ring = app.state.session.getRing(); - ring.addRingingListener(setRinging); - const contact = app.state.session.getContact(); - contact.addCardListener(setContacts); - return () => { - ring.removeRingingListener(setRinging); - contact.removeCardListener(setContacts); - } - } - }, [app.state.session]); - - const actions = { - end: async () => { - if (!call.current) { - throw new Error('no active call'); - } - const { link, peer } = call.current; - try { - peer.close(); - link.close(); - } catch (err) { - console.log(err); - } - call.current = null; - stream.current = null; - updateState({ calling: null, audio: null, video: null }); - }, - accept: async (callId: string, call: Call) => { - if (call.current) { - throw new Error('active call in progress'); - } - const { cardId, node } = call; - const ring = app.state.session.getRing(); - const link = await ring.accept(cardId, callId, node); - const ice = link.getIce(); - const peer = transmit(ice); - const policy = 'impolite'; - const candidates = []; - call.current = { policy, peer, link, candidates }; - link.setStatusListener(linkStatus); - link.setMessageListener(linkMessage); - updateState({ calling: call.card }); - }, - call: async (cardId: string) => { - if (call.current) { - throw new Error('active call in proegress'); - } - const card = state.cards.find(contact => contact.cardId === cardId); - if (!card) { - throw new Error('calling contact not found'); - } - const contact = app.state.session.getContact(); - const link = await contact.callCard(cardId); - const ice = link.getIce(); - const peer = transmit(ice); - const policy = 'polite'; - const candidates = []; - call.current = { policy, peer, link, candidates }; - link.setStatusListener(linkStatus); - link.setMessageListener(linkMessage); - updateState({ calling: card }); - }, - loaded: (e) => { - const { width, height } = e.nativeEvent.layout; - if (width > (height + 80)) { - updateState({ panelOffset: 0, loaded: true }); - } else { - updateState({ panelOffset: ((height - width) - 80) / 2, loaded: true }); - } - }, - enableAudio: async () => { - if (!call.current || !state.audio || !state.audioAdded) { - throw new Error('cannot unmute audio'); - } - state.audio.enabled = true; - updateState({ audioEnabled: true }); - }, - disableAudio: () => { - if (!call.current || !state.audio || !state.audioAdded) { - throw new Error('cannot mute audio'); - } - state.audio.enabled = false; - updateState({ audioEnabled: false }); - }, - enableVideo: () => { - if (!call.current || !state.video) { - throw new Error('cannot start video'); - } - if (!state.videoAdded) { - call.current.peer.addTrack(state.video, stream.current); - const local = new MediaStream(); - local.addTrack(state.video, local); - updateState({ local }); - } - state.video.enabled = true; - updateState({ videoAdded: true, videoEnabled: true }); - }, - disableVideo: () => { - if (!call.current || !state.video) { - throw new Error('cannot stop video'); - } - state.video.enabled = false; - updateState({ videoEnabled: false }); - }, - } - - return { state, actions } -} diff --git a/app/client/mobile/src/db.path b/app/client/mobile/src/db.path deleted file mode 100644 index c978630c..00000000 --- a/app/client/mobile/src/db.path +++ /dev/null @@ -1 +0,0 @@ -/Users/rolandosborne/Library/Developer/CoreSimulator/Devices/A017730F-AC73-4ABE-AE12-C105BCEA1AD5/data/Containers/Data/Application/DC451C73-674B-47A7-B70C-D76CB45E7F8C/Library/LocalDatabase/db_v239.db diff --git a/app/client/mobile/src/session/sbu b/app/client/mobile/src/session/sbu deleted file mode 100644 index a4059fbb..00000000 --- a/app/client/mobile/src/session/sbu +++ /dev/null @@ -1,213 +0,0 @@ -import React, {useState} from 'react'; -import {SafeAreaView, View, useColorScheme} from 'react-native'; -import {styles} from './Session.styled'; -import {BottomNavigation, Surface, Text} from 'react-native-paper'; -import {Settings} from '../settings/Settings'; -import {Channels} from '../channels/Channels'; -import {Contacts} from '../contacts/Contacts'; -import {Registry} from '../registry/Registry'; -import {Profile, ContactParams} from '../profile/Profile'; -import {Details} from '../details/Details'; -import {Identity} from '../identity/Identity'; -import {useSession} from './useSession.hook'; - -import { - NavigationContainer, - DefaultTheme, - DarkTheme, -} from '@react-navigation/native'; -import {createDrawerNavigator} from '@react-navigation/drawer'; -import { createStackNavigator } from '@react-navigation/stack'; - -const SettingsDrawer = createDrawerNavigator(); -const ContactsDrawer = createDrawerNavigator(); -const RegistryDrawer = createDrawerNavigator(); -const ProfileDrawer = createDrawerNavigator(); -const DetailsDrawer = createDrawerNavigator(); - -const ContactStack = createStackNavigator(); -const TopicStack = createStackNavigator(); - -export function Session() { - const {state} = useSession(); - const scheme = useColorScheme(); - const [index, setIndex] = useState(0); - const [routes] = useState([ - { - key: 'channels', - title: 'Channels', - focusedIcon: 'comment-multiple', - unfocusedIcon: 'comment-multiple-outline', - }, - { - key: 'contacts', - title: 'Contacts', - focusedIcon: 'contacts', - unfocusedIcon: 'contacts-outline', - }, - { - key: 'settings', - title: 'Settings', - focusedIcon: 'cog', - unfocusedIcon: 'cog-outline', - }, - ]); - const sessionNav = {strings: state.strings}; - - const ChannelsRoute = () => ; - const SettingsRoute = () => ; - - const renderScene = BottomNavigation.SceneMap({ - channels: ChannelsRoute, - contacts: () => , - settings: SettingsRoute, - }); - - return ( - - {state.layout !== 'large' && ( - - - - )} - {state.layout === 'large' && ( - - - - )} - - ); -} - -function ContactTab() { - return ( - - - - {(props) => {console.log('openreg')}} openContact={(params: ContactParams)=>{console.log('opencon', params)}} />} - - - - ); -} - -function DetailsScreen({nav}) { - return ( - - - {({navigation}) => ( - - )} - - - ); -} - -function ProfileScreen({nav}) { - return ( - - - {({navigation}) => ( - - )} - - - ); -} - -function RegistryScreen({nav}) { - return ( - - - {({navigation}) => ( - - )} - - - ); -} - -function ContactsScreen({nav}) { - return ( - {console.log('openreg')}} openContact={(params: ContactParams)=>{console.log('opencon', params)}} />} - screenOptions={{ - drawerPosition: 'right', - drawerType: 'front', - headerShown: false, - }}> - - {({navigation}) => ( - - )} - - - ); -} - -function SettingsScreen({nav}) { - return ( - - - {({navigation}) => } - - - ); -} - -function HomeScreen({nav}) { - return ( - - - - - - - CHANNELS - - - - CONVERSATION - - - ); -} diff --git a/app/client/mobile/src/todo.txt b/app/client/mobile/src/todo.txt deleted file mode 100644 index d8eae689..00000000 --- a/app/client/mobile/src/todo.txt +++ /dev/null @@ -1,73 +0,0 @@ -message: - | header - | share - | edit - | delete - | block - | report - | text - | carousel - | image - | audio - | video - | binary - | sanitize and tap - | unlock seal while open - | thumb as object not callback - | show skeleton until confirmed - | show skeleton until asset ready -add: - | text - | carousel - | image - | audio - | video - | binary -header: - | status icons - | details icon -details: - | subject - | actions - | members -channels: - - use names - | highlight active - | sdk dont parse unconfirmed: warn: invalid sealed topic - | show unseale summary -contacts: - | avoid self connection - | direct message -settings: - | blocked items - -***** - -contact indicator -call module -welcome component -node admin -share sheet [mobile] -splash screen [mobile] -avoid flash of access [mobile] -tool tips [web] -manage block entities -persist offsync contacts [web] -merge strings -light theme - -***** - -fdroid w/ unified push support -deploy docker/ios/android/fdroid/openwrt -api updates -group management -reactions and read receipt -photo album -music playlist -repeater bot - - - - -