add button to clear call history

This commit is contained in:
liamcottle
2024-05-23 23:34:33 +12:00
parent 4c953ced2b
commit e2f62d46c4
3 changed files with 43 additions and 1 deletions

View File

@@ -239,6 +239,11 @@
</svg> </svg>
</div> </div>
<div class="my-auto">Call History</div> <div class="my-auto">Call History</div>
<div class="ml-auto">
<button @click="clearCallHistory" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
Clear All
</button>
</div>
</div> </div>
<div class="divide-y"> <div class="divide-y">
<div v-for="audioCall in inactiveAudioCalls" class="group flex p-2"> <div v-for="audioCall in inactiveAudioCalls" class="group flex p-2">
@@ -730,6 +735,26 @@
// do nothing on error // 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() { async announce() {
try { try {

View File

@@ -132,7 +132,11 @@ class AudioCallManager:
def delete_audio_call_by_link_hash(self, link_hash: bytes): def delete_audio_call_by_link_hash(self, link_hash: bytes):
audio_call = self.find_audio_call_by_link_hash(link_hash) audio_call = self.find_audio_call_by_link_hash(link_hash)
if audio_call is not None: 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 # hangup all calls
def hangup_all(self): def hangup_all(self):

13
web.py
View File

@@ -175,6 +175,19 @@ class ReticulumWebChat:
"audio_calls": audio_calls, "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 # hangup all calls
@routes.get("/api/v1/calls/hangup-all") @routes.get("/api/v1/calls/hangup-all")
async def index(request): async def index(request):