2025-01-15 19:07:21 +00:00
|
|
|
<script lang="ts">
|
2026-09-07 20:39:58 +00:00
|
|
|
import {onMount} from "svelte"
|
2026-01-28 22:08:15 +00:00
|
|
|
import {assoc} from "@welshman/lib"
|
2025-09-10 22:26:39 +00:00
|
|
|
import Check from "@assets/icons/check.svg?dataurl"
|
2025-09-09 16:54:08 +00:00
|
|
|
import Bell from "@assets/icons/bell.svg?dataurl"
|
|
|
|
|
import BellOff from "@assets/icons/bell-off.svg?dataurl"
|
2025-01-15 19:07:21 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {setChecked} from "@app/notifications"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {notificationSettings} from "@app/settings"
|
2025-01-15 19:07:21 +00:00
|
|
|
|
2026-09-07 20:39:58 +00:00
|
|
|
type Props = {
|
|
|
|
|
onClick: () => void
|
2025-01-15 19:07:21 +00:00
|
|
|
}
|
2025-09-09 16:54:08 +00:00
|
|
|
|
2026-09-07 20:39:58 +00:00
|
|
|
const {onClick}: Props = $props()
|
2025-09-09 16:54:08 +00:00
|
|
|
|
2026-09-07 20:39:58 +00:00
|
|
|
const markAsRead = () => setChecked("/chat/*")
|
|
|
|
|
|
|
|
|
|
const toggleAlerts = () =>
|
|
|
|
|
notificationSettings.update(assoc("messages", !$notificationSettings.messages))
|
|
|
|
|
|
|
|
|
|
let ul: Element
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
ul.addEventListener("click", onClick)
|
|
|
|
|
})
|
2025-01-15 19:07:21 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-09-07 20:39:58 +00:00
|
|
|
<ul class="menu whitespace-nowrap rounded-2xl bg-surface p-2" bind:this={ul}>
|
|
|
|
|
<li>
|
|
|
|
|
<Button onclick={markAsRead}>
|
|
|
|
|
<Icon size={4} icon={Check} />
|
|
|
|
|
Mark all read
|
|
|
|
|
</Button>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<Button onclick={toggleAlerts}>
|
2026-02-10 19:39:29 +00:00
|
|
|
{#if $notificationSettings.messages}
|
2026-09-07 20:39:58 +00:00
|
|
|
<Icon size={4} icon={BellOff} />
|
|
|
|
|
Disable alerts
|
2026-02-10 19:39:29 +00:00
|
|
|
{:else}
|
2026-09-07 20:39:58 +00:00
|
|
|
<Icon size={4} icon={Bell} />
|
|
|
|
|
Enable alerts
|
2026-02-10 19:39:29 +00:00
|
|
|
{/if}
|
2026-09-07 20:39:58 +00:00
|
|
|
</Button>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|