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 @@
-
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):