flotilla/src/app/components/ChatMenu.svelte

70 lines
2.1 KiB
Svelte
Raw Normal View History

2025-01-15 19:07:21 +00:00
<script lang="ts">
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"
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"
import {notificationSettings} from "@app/settings"
2025-01-15 19:07:21 +00:00
type Props = {
onClick: () => void
2025-01-15 19:07:21 +00:00
}
const {onClick}: Props = $props()
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),
})
let ul: Element
onMount(() => {
ul.addEventListener("click", onClick)
})
2025-01-15 19:07:21 +00:00
</script>
<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}
<Icon size={4} icon={BellOff} />
Disable alerts
2026-02-10 19:39:29 +00:00
{:else}
<Icon size={4} icon={Bell} />
Enable alerts
2026-02-10 19:39:29 +00:00
{/if}
</Button>
</li>
2026-09-07 21:39:01 +00:00
<li>
<Button onclick={showRelays}>
<Icon size={4} icon={Mailbox} />
DM relays
</Button>
</li>
</ul>