diff --git a/public/call.html b/public/call.html
index 4f8f012..5fc7c49 100644
--- a/public/call.html
+++ b/public/call.html
@@ -239,6 +239,11 @@
@@ -730,6 +735,26 @@
// do nothing on error
}
+ },
+ async clearCallHistory() {
+
+ // confirm user wants to clear call history
+ if(!confirm("Are you sure you want to clear your call history?")){
+ return;
+ }
+
+ try {
+
+ // clear call history
+ await window.axios.post(`/api/v1/calls/clear-call-history`);
+
+ // update ui
+ await this.updateCallsList()
+
+ } catch(e) {
+ // do nothing on error
+ }
+
},
async announce() {
try {
diff --git a/src/audio_call_manager.py b/src/audio_call_manager.py
index 63f654d..ff6cb74 100644
--- a/src/audio_call_manager.py
+++ b/src/audio_call_manager.py
@@ -132,7 +132,11 @@ class AudioCallManager:
def delete_audio_call_by_link_hash(self, link_hash: bytes):
audio_call = self.find_audio_call_by_link_hash(link_hash)
if audio_call is not None:
- self.audio_calls.remove(audio_call)
+ self.delete_audio_call(audio_call)
+
+ # delete an existing audio call
+ def delete_audio_call(self, audio_call: AudioCall):
+ self.audio_calls.remove(audio_call)
# hangup all calls
def hangup_all(self):
diff --git a/web.py b/web.py
index 676e729..dcbc34f 100644
--- a/web.py
+++ b/web.py
@@ -175,6 +175,19 @@ class ReticulumWebChat:
"audio_calls": audio_calls,
})
+ # clear call history
+ @routes.post("/api/v1/calls/clear-call-history")
+ async def index(request):
+
+ # delete inactive calls, which are classed as call history
+ for audio_call in self.audio_call_manager.audio_calls:
+ if audio_call.is_active() is False:
+ self.audio_call_manager.delete_audio_call(audio_call)
+
+ return web.json_response({
+ "message": "Call history has been cleared",
+ })
+
# hangup all calls
@routes.get("/api/v1/calls/hangup-all")
async def index(request):