mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +00:00
fixing lint
This commit is contained in:
parent
0e1d08d932
commit
b508c1f102
@ -2250,7 +2250,7 @@ SPEC CHECKSUMS:
|
|||||||
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
||||||
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
|
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
|
||||||
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
|
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
|
||||||
Yoga: b05994d1933f507b0a28ceaa4fdb968dc18da178
|
Yoga: a9ef4f5c2cd79ad812110525ef61048be6a582a4
|
||||||
|
|
||||||
PODFILE CHECKSUM: 9cf7373afef7b881c911fda82ff1f94eacee3e98
|
PODFILE CHECKSUM: 9cf7373afef7b881c911fda82ff1f94eacee3e98
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import {NativeCrypto} from '../NativeCrypto';
|
|||||||
import {LocalStore} from '../LocalStore';
|
import {LocalStore} from '../LocalStore';
|
||||||
import { StagingFiles } from '../StagingFiles'
|
import { StagingFiles } from '../StagingFiles'
|
||||||
import messaging from '@react-native-firebase/messaging';
|
import messaging from '@react-native-firebase/messaging';
|
||||||
const DATABAG_DB = 'db_v240.db';
|
const DATABAG_DB = 'db_v241.db';
|
||||||
const SETTINGS_DB = 'ls_v001.db';
|
const SETTINGS_DB = 'ls_v001.db';
|
||||||
|
|
||||||
async function requestUserPermission() {
|
async function requestUserPermission() {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,22 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import classes from './Calling.module.css'
|
import classes from './Calling.module.css'
|
||||||
import { useCalling } from './useCalling.hook';
|
import { useCalling, type Ring } from './useCalling.hook';
|
||||||
import { Card } from '../card/Card';
|
import { Card } from '../card/Card';
|
||||||
import { Loader, Image, Text, ActionIcon } from '@mantine/core'
|
import { Loader, Image, Text, ActionIcon } from '@mantine/core'
|
||||||
import { IconEyeX, IconPhone, IconPhoneOff, IconMicrophone, IconMicrophoneOff, IconVideo, IconVideoOff } from '@tabler/icons-react'
|
import { IconEyeX, IconPhone, IconPhoneOff, IconMicrophone, IconMicrophoneOff, IconVideo, IconVideoOff } from '@tabler/icons-react'
|
||||||
import { modals } from '@mantine/modals'
|
import { modals } from '@mantine/modals'
|
||||||
import { Colors } from '../constants/Colors'
|
import { Colors } from '../constants/Colors'
|
||||||
|
|
||||||
export function Calling({ callCard }: { callCard: string }) {
|
export function Calling({ callCard }: { callCard: { cardId: null|string }}) {
|
||||||
const [connecting, setConnecting] = useState(false);
|
const [connecting, setConnecting] = useState(false);
|
||||||
const [ending, setEnding] = useState(false);
|
const [ending, setEnding] = useState(false);
|
||||||
const [applyingVideo, setApplyingVideo] = useState(false);
|
const [applyingVideo, setApplyingVideo] = useState(false);
|
||||||
const [applyingAudio, setApplyingAudio] = useState(false);
|
const [applyingAudio, setApplyingAudio] = useState(false);
|
||||||
const [ignoring, setIgnoring] = useState(false);
|
const [ignoring, setIgnoring] = useState(null as null|string);
|
||||||
const [declining, setDeclining] = useState(false);
|
const [declining, setDeclining] = useState(null as null|string);
|
||||||
const [accepting, setAccepting] = useState(false);
|
const [accepting, setAccepting] = useState(null as null|string);
|
||||||
const remote = useRef();
|
const remote = useRef(null as null|HTMLVideoElement);
|
||||||
const local = useRef();
|
const local = useRef(null as null|HTMLVideoElement);
|
||||||
const { state, actions } = useCalling();
|
const { state, actions } = useCalling();
|
||||||
|
|
||||||
const showError = () => {
|
const showError = () => {
|
||||||
@ -93,11 +93,11 @@ export function Calling({ callCard }: { callCard: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const accept = async (callId, card) => {
|
const accept = async (ring: Ring) => {
|
||||||
if (!accepting) {
|
if (!accepting) {
|
||||||
setAccepting(callId);
|
setAccepting(ring.callId);
|
||||||
try {
|
try {
|
||||||
await actions.accept(callId, card);
|
await actions.accept(ring.callId, ring.card);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
showError();
|
showError();
|
||||||
@ -106,11 +106,11 @@ export function Calling({ callCard }: { callCard: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ignore = async (callId, card) => {
|
const ignore = async (ring: Ring) => {
|
||||||
if (!ignoring) {
|
if (!ignoring) {
|
||||||
setIgnoring(callId);
|
setIgnoring(ring.callId);
|
||||||
try {
|
try {
|
||||||
await actions.ignore(callId, card);
|
await actions.ignore(ring.callId, ring.card);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
showError();
|
showError();
|
||||||
@ -119,11 +119,11 @@ export function Calling({ callCard }: { callCard: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const decline = async (callId, card) => {
|
const decline = async (ring: Ring) => {
|
||||||
if (!declining) {
|
if (!declining) {
|
||||||
setDeclining(callId);
|
setDeclining(ring.callId);
|
||||||
try {
|
try {
|
||||||
await actions.decline(callId, card);
|
await actions.decline(ring.callId, ring.card);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
showError();
|
showError();
|
||||||
@ -132,21 +132,9 @@ export function Calling({ callCard }: { callCard: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const alertParams = {
|
|
||||||
title: state.strings.operationFailed,
|
|
||||||
prompt: state.strings.tryAgain,
|
|
||||||
cancel: {
|
|
||||||
label: state.strings.close,
|
|
||||||
action: () => {
|
|
||||||
setAlert(false);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { cardId } = callCard;
|
if (callCard?.cardId) {
|
||||||
if (cardId) {
|
call(callCard.cardId);
|
||||||
call(cardId);
|
|
||||||
}
|
}
|
||||||
}, [callCard]);
|
}, [callCard]);
|
||||||
|
|
||||||
@ -166,12 +154,11 @@ export function Calling({ callCard }: { callCard: string }) {
|
|||||||
}
|
}
|
||||||
}, [state.remoteStream]);
|
}, [state.remoteStream]);
|
||||||
|
|
||||||
const calls = state.calls.map((contact, index) => {
|
const calls = state.calls.map((ring, index) => {
|
||||||
const { callId, card } = contact;
|
const { name, handle, node, imageUrl } = ring.card;
|
||||||
const { name, handle, node, imageUrl } = card;
|
const ignoreButton = <ActionIcon key="ignore" variant="subtle" loading={ignoring===ring.callId} onClick={()=>ignore(ring)} color={Colors.pending}><IconEyeX /></ActionIcon>
|
||||||
const ignoreButton = <ActionIcon key="ignore" variant="subtle" loading={ignoring===callId} onClick={()=>ignore(callId, card)} color={Colors.pending}><IconEyeX /></ActionIcon>
|
const declineButton = <div key="decline" className={classes.space}><ActionIcon variant="subtle" loading={declining===ring.callId} onClick={()=>decline(ring)} color={Colors.offsync}><IconPhone className={classes.off} /></ActionIcon></div>
|
||||||
const declineButton = <div key="decline" className={classes.space}><ActionIcon variant="subtle" loading={declining===callId} onClick={()=>decline(callId, card)} color={Colors.offsync}><IconPhone className={classes.off} /></ActionIcon></div>
|
const acceptButton = <ActionIcon key="accept" variant="subtle" loading={accepting===ring.callId} onClick={()=>accept(ring)} color={Colors.primary}><IconPhone /></ActionIcon>
|
||||||
const acceptButton = <ActionIcon key="accept" variant="subtle" loading={accepting===callId} onClick={()=>accept(callId, card)} color={Colors.primary}><IconPhone /></ActionIcon>
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={index} className={classes.caller}>
|
<div key={index} className={classes.caller}>
|
||||||
|
@ -4,6 +4,11 @@ import { AppContext } from '../context/AppContext'
|
|||||||
import { ContextType } from '../context/ContextType'
|
import { ContextType } from '../context/ContextType'
|
||||||
import { Link, type Card } from 'databag-client-sdk';
|
import { Link, type Card } from 'databag-client-sdk';
|
||||||
|
|
||||||
|
export type Ring = {
|
||||||
|
callId: string,
|
||||||
|
card: Card,
|
||||||
|
}
|
||||||
|
|
||||||
export function useCalling() {
|
export function useCalling() {
|
||||||
const app = useContext(AppContext) as ContextType;
|
const app = useContext(AppContext) as ContextType;
|
||||||
const display = useContext(DisplayContext) as ContextType;
|
const display = useContext(DisplayContext) as ContextType;
|
||||||
@ -16,9 +21,9 @@ export function useCalling() {
|
|||||||
const peerUpdate = useRef([] as {type: string, data?: any}[]);
|
const peerUpdate = useRef([] as {type: string, data?: any}[]);
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
strings: {},
|
strings: display.state.strings,
|
||||||
ringing: [] as { cardId: string, callId: string }[],
|
ringing: [] as { cardId: string, callId: string }[],
|
||||||
calls: [],
|
calls: [] as Ring[],
|
||||||
cards: [] as Card[],
|
cards: [] as Card[],
|
||||||
calling: null as null | Card,
|
calling: null as null | Card,
|
||||||
failed: false,
|
failed: false,
|
||||||
@ -77,25 +82,25 @@ export function useCalling() {
|
|||||||
if (call.current) {
|
if (call.current) {
|
||||||
const { policy, peer, link } = call.current;
|
const { policy, peer, link } = call.current;
|
||||||
if (status === 'connected') {
|
if (status === 'connected') {
|
||||||
|
localVideo.current = null;
|
||||||
|
localStream.current = null;
|
||||||
|
remoteStream.current = new MediaStream();
|
||||||
|
updateState({ localStream: localStream.current, remoteStream: remoteStream.current,
|
||||||
|
audioEnabled: false, videoEnabled: false, localVideo: false, remoteVideo: false, connected: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const audioStream = await getAudioStream(null);
|
const audioStream = await getAudioStream(null);
|
||||||
const audioTrack = audioStream.getTracks().find((track: MediaStreamTrack) => track.kind === 'audio');
|
const audioTrack = audioStream.getTracks().find((track: MediaStreamTrack) => track.kind === 'audio');
|
||||||
if (audioTrack) {
|
if (audioTrack) {
|
||||||
localAudio.current = audioTrack;
|
localAudio.current = audioTrack;
|
||||||
}
|
}
|
||||||
localVideo.current = null;
|
|
||||||
localStream.current = null;
|
|
||||||
remoteStream.current = new MediaStream();
|
|
||||||
|
|
||||||
if (localAudio.current) {
|
if (localAudio.current) {
|
||||||
localAudio.current.enabled = true;
|
localAudio.current.enabled = true;
|
||||||
await updatePeer('local_track', { track: audioTrack, stream: audioStream });
|
await updatePeer('local_track', { track: audioTrack, stream: audioStream });
|
||||||
|
updateState({ audioEnabled: true });
|
||||||
}
|
}
|
||||||
updateState({ localStream: localStream.current, remoteStream: remoteStream.current,
|
|
||||||
audioEnabled: true, videoEnabled: false, localVideo: false, remoteVideo: false, connected: true });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
updateState({ failed: true });
|
|
||||||
}
|
}
|
||||||
} else if (status === 'closed') {
|
} else if (status === 'closed') {
|
||||||
updatePeer('close');
|
updatePeer('close');
|
||||||
@ -316,7 +321,17 @@ export function useCalling() {
|
|||||||
if (!call.current) {
|
if (!call.current) {
|
||||||
throw new Error('cannot unmute audio');
|
throw new Error('cannot unmute audio');
|
||||||
}
|
}
|
||||||
if (localAudio.current) {
|
if (!localAudio.current) {
|
||||||
|
const audioStream = await getAudioStream(null);
|
||||||
|
const audioTrack = audioStream.getTracks().find((track: MediaStreamTrack) => track.kind === 'audio');
|
||||||
|
if (!audioTrack) {
|
||||||
|
throw new Error('no available audio track');
|
||||||
|
}
|
||||||
|
localAudio.current = audioTrack;
|
||||||
|
localStream.current = audioStream;
|
||||||
|
updatePeer('local_track', { track: audioTrack, stream: audioStream });
|
||||||
|
updateState({ localAudio: true, localStream: audioStream, audioEnabled: true });
|
||||||
|
} else {
|
||||||
localAudio.current.enabled = true;
|
localAudio.current.enabled = true;
|
||||||
updateState({ audioEnabled: true });
|
updateState({ audioEnabled: true });
|
||||||
}
|
}
|
||||||
|
13472
app/client/web/yarn.lock
13472
app/client/web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user