flotilla/src/app/components/SpaceMenuRoomItem.svelte

43 lines
1.6 KiB
Svelte
Raw Normal View History

2024-11-14 18:53:13 +00:00
<script lang="ts">
import Bell from "@assets/icons/bell.svg?dataurl"
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"
import {deriveShouldNotify} 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-02-02 22:29:12 +00:00
const shouldNotifyForSpace = deriveShouldNotify(url)
const shouldNotifyForRoom = deriveShouldNotify(url, h)
const showDifferenceIcon = $derived($shouldNotifyForRoom !== $shouldNotifyForSpace)
const notification = $derived($shouldNotifyForRoom ? $notifications.has(path) : false)
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} />
{#if showDifferenceIcon}
<Icon icon={$shouldNotifyForRoom ? Bell : BellOff} size={4} class="ml-auto opacity-50" />
{/if}
</SecondaryNavItem>
{/if}