From b1ec6ac608c149d52ab3de6b17ddebd3ed8102fb Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 20 May 2024 23:48:47 +1200 Subject: [PATCH] add ui to initiate a new call to provided destination --- public/call.html | 49 ++++++++++++++++++++++++++++++++++++++---------- web.py | 1 + 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/public/call.html b/public/call.html index 32194a9..164377d 100644 --- a/public/call.html +++ b/public/call.html @@ -92,14 +92,14 @@ -
Reticulum Phone
+
Start a new Call
- +
-
@@ -109,7 +109,7 @@
- +
Call Log
@@ -152,6 +152,8 @@ audioCalls: [], + isInitiatingCall: false, + isWebsocketConnected: false, callHash: null, txBytes: 0, @@ -180,15 +182,42 @@ }, methods: { - async joinExistingCall() { + async initiateCall(destinationHash) { - // make sure call hash provided - if(!this.callHash) { - alert("Enter hash of existing call."); + // do nothing if already initiating call + // todo: support cancelling in progress call initiation + if(this.isInitiatingCall){ + alert("Call is already initiating..."); return; } - await this.joinCall(this.callHash); + // make sure call hash provided + if(!destinationHash) { + alert("Enter destination hash to call."); + return; + } + + // show loading + this.isInitiatingCall = true; + + try { + + // initiate call + const response = await axios.get(`/api/v1/calls/initiate/${destinationHash}`); + + // get call hash from response + const hash = response.data.hash; + + // join call + await this.joinCall(hash); + + } catch(e) { + alert("failed to initiate call"); + console.log(e); + } finally { + // hide loading + this.isInitiatingCall = false; + } }, async joinCall(callHash) { diff --git a/web.py b/web.py index b1dbe8d..576f08a 100644 --- a/web.py +++ b/web.py @@ -156,6 +156,7 @@ class ReticulumWebChat: return websocket_response # handle websocket clients for initiating a call + # todo: remove @routes.get("/call/initiate/{destination_hash}") async def ws(request):