From 960f113bafc11491a1fe6c8cc9067de417d846b2 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 18 Oct 2024 18:05:02 -0300 Subject: [PATCH 1/3] Show feedback for other users about other users in call --- src/lib/components/calling/CallScreen.svelte | 15 +++++++++++++-- src/lib/media/Voice.ts | 8 ++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/components/calling/CallScreen.svelte b/src/lib/components/calling/CallScreen.svelte index 86094c1e0..3e17aa3e5 100644 --- a/src/lib/components/calling/CallScreen.svelte +++ b/src/lib/components/calling/CallScreen.svelte @@ -13,7 +13,7 @@ import type { Chat } from "$lib/types" import VolumeMixer from "./VolumeMixer.svelte" import { createEventDispatcher, onDestroy, onMount } from "svelte" - import { callTimeout, TIME_TO_SHOW_CONNECTING, TIME_TO_SHOW_END_CALL_FEEDBACK, usersAcceptedTheCall, usersDeniedTheCall, VoiceRTCInstance } from "$lib/media/Voice" + import { callTimeout, TIME_TO_SHOW_CONNECTING, TIME_TO_SHOW_END_CALL_FEEDBACK, timeCallStarted, usersAcceptedTheCall, usersDeniedTheCall, VoiceRTCInstance } from "$lib/media/Voice" import { log } from "$lib/utils/Logger" import { playSound, SoundHandler, Sounds } from "../utils/SoundHandler" @@ -155,6 +155,17 @@ }, TIME_TO_SHOW_CONNECTING) } } + if ($timeCallStarted) { + let timeCallStartedInterval = setInterval(() => { + let now = new Date() + let timeDifference = now.getTime() - $timeCallStarted.getTime() + if (timeDifference > TIME_TO_SHOW_CONNECTING) { + showAnimation = false + message = $_("settings.calling.noResponse") + clearInterval(timeCallStartedInterval) + } + }, 1000) + } if (VoiceRTCInstance.localVideoCurrentSrc) { await VoiceRTCInstance.getLocalStream(true) @@ -214,7 +225,7 @@ {#each chat.users as user (user)} {#if user === get(Store.state.user).key && !userCallOptions.video.enabled} - {:else if $userCache[user] && $userCache[user].key !== get(Store.state.user).key && VoiceRTCInstance.toCall && !$remoteStreams[user]} + {:else if $userCache[user] && $userCache[user].key !== get(Store.state.user).key && !$remoteStreams[user]} {#if showAnimation && !$usersAcceptedTheCall.includes(user)}
diff --git a/src/lib/media/Voice.ts b/src/lib/media/Voice.ts index e1f8cda2e..0538a1759 100644 --- a/src/lib/media/Voice.ts +++ b/src/lib/media/Voice.ts @@ -16,16 +16,17 @@ export const TIME_TO_SHOW_END_CALL_FEEDBACK = 3500 export const TIME_TO_SHOW_CONNECTING = 30000 let timeOuts: NodeJS.Timeout[] = [] + export const usersDeniedTheCall: Writable = writable([]) export const usersAcceptedTheCall: Writable = writable([]) +export const connectionOpened = writable(false) +export const timeCallStarted: Writable = writable(null) export enum VoiceRTCMessageType { UpdateUser = "UPDATE_USER", None = "NONE", } -export const connectionOpened = writable(false) - export type RemoteStream = { user: VoiceRTCUser stream: MediaStream | null @@ -215,6 +216,7 @@ export class CallRoom { participant[1].handleRemoteStream(stream) } }) + room.onPeerTrack((stream, peer, _meta) => {}) // room.onPeerTrack((stream, peer, meta) => {}) } @@ -397,6 +399,7 @@ export class VoiceRTC { log.info(`Receiving connection on channel: ${conn.metadata.channel} from ${conn.metadata.id}, username: ${conn.metadata.username}`) this.incomingConnections.push(conn) this.incomingCallFrom = [conn.metadata.channel, conn] + timeCallStarted.set(new Date(conn.metadata.timeCallStarted)) Store.setPendingCall(Store.getCallingChat(this.channel!)!, CallDirection.Inbound) }) @@ -505,6 +508,7 @@ export class VoiceRTC { did: get(Store.state.user).key, username: get(Store.state.user).name, channel: this.channel, + timeCallStarted: new Date().toISOString(), }, }) conn.on("open", () => { From aa40cf9a40d8183c976f71bc9b39bdd472ce3ce7 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 18 Oct 2024 18:13:24 -0300 Subject: [PATCH 2/3] Hide no response users after a period of time --- src/lib/components/calling/CallScreen.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/components/calling/CallScreen.svelte b/src/lib/components/calling/CallScreen.svelte index 3e17aa3e5..cf919fc85 100644 --- a/src/lib/components/calling/CallScreen.svelte +++ b/src/lib/components/calling/CallScreen.svelte @@ -127,10 +127,17 @@ } let showAnimation = true + let noResponseVisible = false let message = $_("settings.calling.connecting") let timeout: NodeJS.Timeout | undefined let callSound: SoundHandler | undefined = undefined + function hideNoResponseUsersAfterAPeriodOfTime() { + setTimeout(() => { + noResponseVisible = false + }, 10000) + } + $: if ($usersAcceptedTheCall.length > 0) { callSound?.stop() callSound = undefined @@ -152,6 +159,8 @@ callSound = undefined showAnimation = false message = $_("settings.calling.noResponse") + noResponseVisible = true + hideNoResponseUsersAfterAPeriodOfTime() }, TIME_TO_SHOW_CONNECTING) } } @@ -161,8 +170,10 @@ let timeDifference = now.getTime() - $timeCallStarted.getTime() if (timeDifference > TIME_TO_SHOW_CONNECTING) { showAnimation = false + noResponseVisible = true message = $_("settings.calling.noResponse") clearInterval(timeCallStartedInterval) + hideNoResponseUsersAfterAPeriodOfTime() } }, 1000) } @@ -238,7 +249,7 @@

{$_("settings.calling.acceptedCall")}

- {:else} + {:else if noResponseVisible}

{message}

From b48bfd179d6926ef843820ce9fe9ec7e133f822f Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Fri, 18 Oct 2024 18:17:40 -0300 Subject: [PATCH 3/3] Just clear timeout created for no response users --- src/lib/components/calling/CallScreen.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/components/calling/CallScreen.svelte b/src/lib/components/calling/CallScreen.svelte index cf919fc85..72e8412d1 100644 --- a/src/lib/components/calling/CallScreen.svelte +++ b/src/lib/components/calling/CallScreen.svelte @@ -130,10 +130,11 @@ let noResponseVisible = false let message = $_("settings.calling.connecting") let timeout: NodeJS.Timeout | undefined + let hideNoResponseUsersTimeout: NodeJS.Timeout | undefined let callSound: SoundHandler | undefined = undefined function hideNoResponseUsersAfterAPeriodOfTime() { - setTimeout(() => { + hideNoResponseUsersTimeout = setTimeout(() => { noResponseVisible = false }, 10000) } @@ -196,6 +197,9 @@ if (timeout) { clearTimeout(timeout) } + if (hideNoResponseUsersTimeout) { + clearTimeout(hideNoResponseUsersTimeout) + } callSound?.stop() callSound = undefined })