Add a right around user avatar when speaking

This commit is contained in:
mplorentz
2026-03-03 16:50:54 -05:00
parent b4c68b66eb
commit b14e592ba7
2 changed files with 18 additions and 2 deletions
+10 -2
View File
@@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import cx from "classnames"
import {loadProfile, displayProfileByPubkey} from "@welshman/app" import {loadProfile, displayProfileByPubkey} from "@welshman/app"
import Volume from "@assets/icons/volume.svg?dataurl" import Volume from "@assets/icons/volume.svg?dataurl"
import Icon from "@lib/components/Icon.svelte" import Icon from "@lib/components/Icon.svelte"
@@ -12,6 +13,7 @@
joinVoiceRoom, joinVoiceRoom,
leaveVoiceRoom, leaveVoiceRoom,
currentVoiceSession, currentVoiceSession,
speakingPubkeys,
} from "@app/voice" } from "@app/voice"
interface Props { interface Props {
@@ -71,10 +73,16 @@
<RoomName {url} {h} /> <RoomName {url} {h} />
</SecondaryNavItem> </SecondaryNavItem>
{#if $participants.length > 0} {#if $participants.length > 0}
<div class="flex flex-col gap-1 pb-1 pl-10"> <div class="mt-2 flex flex-col gap-1 pb-1 pl-10">
{#each $participants as pk (pk)} {#each $participants as pk (pk)}
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<ProfileCircle pubkey={pk} size={5} class="h-5 w-5" /> <div
class={cx(
"inline-flex shrink-0 items-center justify-center rounded-full transition-shadow",
isActive && $speakingPubkeys.has(pk) && "ring-2 ring-success",
)}>
<ProfileCircle pubkey={pk} size={5} class="h-5 w-5" />
</div>
<span class="ellipsize text-xs opacity-70"> <span class="ellipsize text-xs opacity-70">
{displayProfileByPubkey(pk)} {displayProfileByPubkey(pk)}
</span> </span>
+8
View File
@@ -46,6 +46,8 @@ export type VoiceSession = {
export const currentVoiceSession = writable<VoiceSession | undefined>(undefined) export const currentVoiceSession = writable<VoiceSession | undefined>(undefined)
export const speakingPubkeys = writable<Set<string>>(new Set())
const fetchLivekitToken = async ( const fetchLivekitToken = async (
url: string, url: string,
groupId: string, groupId: string,
@@ -157,6 +159,7 @@ export const joinVoiceRoom = async (
}) })
room.on(RoomEvent.Disconnected, (reason?: DisconnectReason) => { room.on(RoomEvent.Disconnected, (reason?: DisconnectReason) => {
speakingPubkeys.set(new Set())
currentVoiceSession.set(undefined) currentVoiceSession.set(undefined)
stopPresenceHeartbeat() stopPresenceHeartbeat()
if (reason !== undefined && reason !== DisconnectReason.CLIENT_INITIATED) { if (reason !== undefined && reason !== DisconnectReason.CLIENT_INITIATED) {
@@ -181,6 +184,10 @@ export const joinVoiceRoom = async (
track.detach().forEach(el => el.remove()) track.detach().forEach(el => el.remove())
}) })
room.on(RoomEvent.ActiveSpeakersChanged, participants => {
speakingPubkeys.set(new Set(participants.map(p => p.identity)))
})
const onAbort = () => { const onAbort = () => {
room.disconnect() room.disconnect()
} }
@@ -225,6 +232,7 @@ export const leaveVoiceRoom = async () => {
const session = get(currentVoiceSession) const session = get(currentVoiceSession)
if (!session) return if (!session) return
speakingPubkeys.set(new Set())
stopPresenceHeartbeat() stopPresenceHeartbeat()
session.room.disconnect() session.room.disconnect()
deletePresence(session.url) deletePresence(session.url)