Новый тип вложений - Attachment.CALL с активными звонками
This commit is contained in:
@@ -13,6 +13,9 @@ import { Button, Flex, Text } from "@mantine/core";
|
||||
import { useSound } from "@/app/hooks/useSound";
|
||||
import useWindow from "@/app/hooks/useWindow";
|
||||
import { attachReceiverE2EE, attachSenderE2EE } from "./audioE2EE";
|
||||
import { useDeattachedSender } from "../DialogProvider/useDeattachedSender";
|
||||
import { AttachmentType } from "../ProtocolProvider/protocol/packets/packet.message";
|
||||
import { generateRandomKey } from "@/app/utils/utils";
|
||||
|
||||
export interface CallContextValue {
|
||||
call: (callable: string) => void;
|
||||
@@ -80,6 +83,7 @@ export function CallProvider(props : CallProviderProps) {
|
||||
const iceCandidatesBufferRef = useRef<RTCIceCandidate[]>([]);
|
||||
const mutedRef = useRef<boolean>(false);
|
||||
const soundRef = useRef<boolean>(true);
|
||||
const {sendMessage} = useDeattachedSender();
|
||||
|
||||
const {playSound, stopSound, stopLoopSound} = useSound();
|
||||
const {setWindowPriority} = useWindow();
|
||||
@@ -434,6 +438,7 @@ export function CallProvider(props : CallProviderProps) {
|
||||
remoteAudioRef.current.pause();
|
||||
remoteAudioRef.current.srcObject = null;
|
||||
}
|
||||
generateCallAttachment();
|
||||
setDuration(0);
|
||||
durationIntervalRef.current && clearInterval(durationIntervalRef.current);
|
||||
setWindowPriority(false);
|
||||
@@ -453,6 +458,27 @@ export function CallProvider(props : CallProviderProps) {
|
||||
roleRef.current = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправляет сообщение в диалог с звонящим с информацией о звонке
|
||||
*/
|
||||
const generateCallAttachment = () => {
|
||||
let preview = "";
|
||||
if(roleRef.current == CallRole.CALLER){
|
||||
preview += "1::";
|
||||
}
|
||||
if(roleRef.current == CallRole.CALLEE){
|
||||
preview += "0::";
|
||||
}
|
||||
preview += duration.toString();
|
||||
|
||||
sendMessage(activeCall, "", [{
|
||||
id: generateRandomKey(16),
|
||||
preview: preview,
|
||||
type: AttachmentType.CALL,
|
||||
blob: ""
|
||||
}], false);
|
||||
}
|
||||
|
||||
const accept = () => {
|
||||
if(callState != CallState.INCOMING){
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user