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"
2026-09-07 21:39:01 +00:00
import { publish } from "@welshman/app"
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"
2026-09-07 21:39:01 +00:00
import Mailbox from "@assets/icons/mailbox.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-09-07 21:39:01 +00:00
import RelayList from "@app/components/RelayList.svelte"
import { messagingRelayLists , user } from "@app/core"
import { pushModal } from "@app/modal"
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))
2026-09-07 21:39:01 +00:00
const showRelays = () =>
pushModal(RelayList, {
title: "DM Relays",
subtitle:
"Where you send and receive direct messages. Be sure to select relays that will accept your messages and messages from people you'd like to be in contact with.",
relays: $messagingRelayLists.urls($user.pubkey).$,
addRelay: (url: string) => $messagingRelayLists.addUrl(url).then(publish),
removeRelay: (url: string) => $messagingRelayLists.removeUrl(url).then(publish),
})
2026-09-07 20:39:58 +00:00
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 >
2026-09-07 21:39:01 +00:00
< li >
< Button onclick = { showRelays } >
< Icon size = { 4 } icon= { Mailbox } />
DM relays
< / Button >
< / li >
2026-09-07 20:39:58 +00:00
< / ul >