From cac6803d18ca9bf25751ddfc436675dfb48dc26e Mon Sep 17 00:00:00 2001 From: liamcottle Date: Wed, 31 Jul 2024 15:56:10 +1200 Subject: [PATCH] show notification for incoming calls --- meshchat.py | 3 +++ public/index.html | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/meshchat.py b/meshchat.py index bcd17a8..a71a25c 100644 --- a/meshchat.py +++ b/meshchat.py @@ -167,6 +167,9 @@ async def announce_loop(self): # handle receiving a new audio call def on_incoming_audio_call(self, audio_call: AudioCall): print("on_incoming_audio_call: {}".format(audio_call.link.hash.hex())) + asyncio.run(self.websocket_broadcast(json.dumps({ + "type": "incoming_audio_call", + }))) # web server has shutdown, likely ctrl+c, but if we don't do the following, the script never exits async def shutdown(self, app): diff --git a/public/index.html b/public/index.html index e455597..b491319 100644 --- a/public/index.html +++ b/public/index.html @@ -1569,6 +1569,17 @@ this.getConfig(); break; } + case 'incoming_audio_call': { + Notification.requestPermission().then((result) => { + if(result === "granted"){ + new window.Notification("Incoming Call", { + body: "Someone is calling you.", + tag: "new_audio_call", // only ever show one notification at a time + }); + } + }); + break; + } case 'lxmf.delivery': { // add inbound message to ui