feature/23-voice-room/poc #93
@@ -25,27 +25,24 @@
|
||||
|
||||
const participants = deriveVoiceParticipants(url, h)
|
||||
const isActive = $derived($currentVoiceSession?.url === url && $currentVoiceSession?.h === h)
|
||||
let isJoining = $state(false)
|
||||
let joinAbortController: AbortController | undefined
|
||||
let joinAbortController = $state<AbortController | undefined>(undefined)
|
||||
|
||||
const handleClick = async () => {
|
||||
if (isActive) {
|
||||
await leaveVoiceRoom()
|
||||
return
|
||||
}
|
||||
if (isJoining) {
|
||||
joinAbortController?.abort()
|
||||
if (joinAbortController) {
|
||||
|
hodlbod marked this conversation as resolved
Outdated
|
||||
joinAbortController.abort()
|
||||
return
|
||||
}
|
||||
joinAbortController = new AbortController()
|
||||
isJoining = true
|
||||
try {
|
||||
await joinVoiceRoom(url, h, joinAbortController.signal)
|
||||
} catch (e) {
|
||||
console.error("Failed to join voice room", e)
|
||||
pushToast({theme: "error", message: "Failed to join voice room"})
|
||||
} finally {
|
||||
|
hodlbod marked this conversation as resolved
Outdated
hodlbod
commented
[nit] in situations like this, I like to overload the controller as the isJoining boolean and just check whether joinAbortController is undefined. One fewer variable to keep track of [nit] in situations like this, I like to overload the controller as the isJoining boolean and just check whether joinAbortController is undefined. One fewer variable to keep track of
|
||||
isJoining = false
|
||||
joinAbortController = undefined
|
||||
}
|
||||
}
|
||||
@@ -62,7 +59,7 @@
|
||||
class={cx("!items-start", isActive && "!bg-base-100 !text-base-content")}>
|
||||
<div class="flex w-full min-w-0 flex-col gap-2">
|
||||
<div class="flex gap-2 items-center">
|
||||
{#if isJoining}
|
||||
{#if joinAbortController}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{:else}
|
||||
<Icon icon={isActive ? VolumeLoud : Volume} size={4} class="opacity-70" />
|
||||
|
||||
Reference in New Issue
Block a user
Instead of this, we should just not render voice rooms on mobile
I tried that, but realized that you could then join a call on desktop web, resize your browser to be small and then lose the UI to leave the call. As I type it out I realize that's too edgy of a case 😂 I will just hide it.