add ability to delete calls from history
This commit is contained in:
@@ -203,7 +203,7 @@
|
|||||||
<div class="my-auto">Call History</div>
|
<div class="my-auto">Call History</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="divide-y">
|
<div class="divide-y">
|
||||||
<div v-for="audioCall in inactiveAudioCalls" class="flex p-2">
|
<div v-for="audioCall in inactiveAudioCalls" class="group flex p-2">
|
||||||
<div class="mr-2 my-auto">
|
<div class="mr-2 my-auto">
|
||||||
<div class="bg-gray-100 p-2 rounded-full">
|
<div class="bg-gray-100 p-2 rounded-full">
|
||||||
<svg v-if="audioCall.is_outbound" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
|
<svg v-if="audioCall.is_outbound" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
|
||||||
@@ -218,19 +218,12 @@
|
|||||||
<div>Destination: {{ audioCall.remote_destination_hash || "Unknown" }}</div>
|
<div>Destination: {{ audioCall.remote_destination_hash || "Unknown" }}</div>
|
||||||
<div class="text-sm text-gray-500">Call Hash: {{ audioCall.hash }}</div>
|
<div class="text-sm text-gray-500">Call Hash: {{ audioCall.hash }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-2 ml-auto my-auto mx-2">
|
<div class="hidden group-hover:flex space-x-2 ml-auto my-auto mx-2">
|
||||||
|
|
||||||
<!-- rejoin call -->
|
<!-- delete call -->
|
||||||
<button v-if="audioCall.is_active" title="Join Call" @click="joinCall(audioCall.hash)" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-green-500 p-2 text-sm font-semibold text-white shadow-sm hover:bg-green-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-green-500">
|
<button @click="deleteCall(audioCall.hash)" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-full bg-red-500 p-2 text-sm font-semibold text-white shadow-sm hover:bg-red-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-500">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-5 h-5">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 6.75c0 8.284 6.716 15 15 15h2.25a2.25 2.25 0 0 0 2.25-2.25v-1.372c0-.516-.351-.966-.852-1.091l-4.423-1.106c-.44-.11-.902.055-1.173.417l-.97 1.293c-.282.376-.769.542-1.21.38a12.035 12.035 0 0 1-7.143-7.143c-.162-.441.004-.928.38-1.21l1.293-.97c.363-.271.527-.734.417-1.173L6.963 3.102a1.125 1.125 0 0 0-1.091-.852H4.5A2.25 2.25 0 0 0 2.25 4.5v2.25Z" />
|
<path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" />
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- hangup call -->
|
|
||||||
<button v-if="audioCall.is_active" title="Hangup Call" @click="hangupCall(audioCall.hash)" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-red-500 p-2 text-sm font-semibold text-white shadow-sm hover:bg-red-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-500">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -605,7 +598,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// get path to destination
|
// fetch call
|
||||||
const response = await window.axios.get(`/api/v1/calls/${callHash}`);
|
const response = await window.axios.get(`/api/v1/calls/${callHash}`);
|
||||||
|
|
||||||
// update ui
|
// update ui
|
||||||
@@ -616,6 +609,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
async deleteCall(callHash) {
|
||||||
|
|
||||||
|
// confirm user wants to delete call
|
||||||
|
if(!confirm("Are you sure you want to delete this call?")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// delete call
|
||||||
|
await window.axios.delete(`/api/v1/calls/${callHash}`);
|
||||||
|
|
||||||
|
// update ui
|
||||||
|
await this.updateCallsList()
|
||||||
|
|
||||||
|
} catch(e) {
|
||||||
|
// do nothing on error
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
activeAudioCalls: function() {
|
activeAudioCalls: function() {
|
||||||
|
|||||||
@@ -123,6 +123,12 @@ class AudioCallManager:
|
|||||||
return audio_call
|
return audio_call
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# delete an existing audio call from the provided link hash
|
||||||
|
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)
|
||||||
|
|
||||||
# attempts to initiate a call to the provided destination and returns the link hash on success
|
# attempts to initiate a call to the provided destination and returns the link hash on success
|
||||||
# FIXME: implement timeout. at the moment, it loops forever if no path is found
|
# FIXME: implement timeout. at the moment, it loops forever if no path is found
|
||||||
async def initiate(self, destination_hash: bytes) -> bytes:
|
async def initiate(self, destination_hash: bytes) -> bytes:
|
||||||
|
|||||||
19
web.py
19
web.py
@@ -260,7 +260,7 @@ class ReticulumWebChat:
|
|||||||
"audio_calls": audio_calls,
|
"audio_calls": audio_calls,
|
||||||
})
|
})
|
||||||
|
|
||||||
# get calls
|
# get call
|
||||||
@routes.get("/api/v1/calls/{audio_call_link_hash}")
|
@routes.get("/api/v1/calls/{audio_call_link_hash}")
|
||||||
async def index(request):
|
async def index(request):
|
||||||
|
|
||||||
@@ -281,6 +281,23 @@ class ReticulumWebChat:
|
|||||||
"audio_call": self.convert_audio_call_to_dict(audio_call),
|
"audio_call": self.convert_audio_call_to_dict(audio_call),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# delete call
|
||||||
|
@routes.delete("/api/v1/calls/{audio_call_link_hash}")
|
||||||
|
async def index(request):
|
||||||
|
|
||||||
|
# get path params
|
||||||
|
audio_call_link_hash = request.match_info.get("audio_call_link_hash", "")
|
||||||
|
|
||||||
|
# convert hash to bytes
|
||||||
|
audio_call_link_hash = bytes.fromhex(audio_call_link_hash)
|
||||||
|
|
||||||
|
# delete audio call
|
||||||
|
self.audio_call_manager.delete_audio_call_by_link_hash(audio_call_link_hash)
|
||||||
|
|
||||||
|
return web.json_response({
|
||||||
|
"message": "audio call deleted",
|
||||||
|
})
|
||||||
|
|
||||||
# initiate a call to the provided destination
|
# initiate a call to the provided destination
|
||||||
@routes.get("/api/v1/calls/initiate/{destination_hash}")
|
@routes.get("/api/v1/calls/initiate/{destination_hash}")
|
||||||
async def index(request):
|
async def index(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user