flotilla/src/app/components/SpaceMenuRoomItem.svelte

40 lines
1.4 KiB
Svelte
Raw Normal View History

2024-11-14 18:53:13 +00:00
<script lang="ts">
import BellOff from "@assets/icons/bell-off.svg?dataurl"
2026-01-22 20:37:30 +00:00
import Icon from "@lib/components/Icon.svelte"
2024-11-14 18:53:13 +00:00
import SecondaryNavItem from "@lib/components/SecondaryNavItem.svelte"
2025-10-30 22:36:14 +00:00
import RoomNameWithImage from "@app/components/RoomNameWithImage.svelte"
import VoiceRoomItem from "@app/components/VoiceRoomItem.svelte"
2026-07-28 16:16:26 +00:00
import {rooms} from "@app/core"
import {RoomType, getRoomType} from "@app/rooms"
2026-09-08 14:57:30 +00:00
import {deriveIsMuted} from "@app/settings"
2026-06-08 21:14:40 +00:00
import {notifications} from "@app/notifications"
import {makeRoomPath} from "@app/routes"
2024-11-14 18:53:13 +00:00
type Props = {
url: string
h: string
replaceState?: boolean
tooltip?: boolean
2025-02-04 00:37:14 +00:00
}
const {url, h, replaceState = false, tooltip = true}: Props = $props()
2024-11-14 18:53:13 +00:00
2026-07-28 16:16:26 +00:00
const room = $rooms.forRoom(url, h)
const roomType = $derived(getRoomType($room))
2025-10-30 22:33:34 +00:00
const path = makeRoomPath(url, h)
2026-09-08 14:57:30 +00:00
const isMuted = deriveIsMuted(url, h)
const notification = $derived($notifications.has(path))
2026-07-28 16:16:26 +00:00
const roomName = $derived($room?.meta?.name() || h)
2024-11-14 18:53:13 +00:00
</script>
{#if roomType === RoomType.Voice}
<VoiceRoomItem {url} {h} {replaceState} {notification} />
{:else}
<SecondaryNavItem href={path} title={tooltip ? roomName : ""} {replaceState} {notification}>
<RoomNameWithImage {url} {h} />
2026-09-08 14:57:30 +00:00
{#if $isMuted}
<Icon icon={BellOff} size={4} class="ml-auto opacity-50" />
{/if}
</SecondaryNavItem>
{/if}