flotilla/src/app/components/ChatMenu.svelte

53 lines
1.7 KiB
Svelte
Raw Normal View History

2025-01-15 19:07:21 +00:00
<script lang="ts">
2026-01-28 22:08:15 +00:00
import {assoc} from "@welshman/lib"
2025-09-10 22:26:39 +00:00
import ChatSquare from "@assets/icons/chat-square.svg?dataurl"
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"
2025-01-15 19:07:21 +00:00
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
2026-02-07 00:27:57 +00:00
import Modal from "@lib/components/Modal.svelte"
import ModalBody from "@lib/components/ModalBody.svelte"
2025-01-15 19:07:21 +00:00
import ChatStart from "@app/components/ChatStart.svelte"
import {setChecked} from "@app/util/notifications"
import {pushModal} from "@app/util/modal"
2026-01-28 22:08:15 +00:00
import {notificationSettings} from "@app/core/state"
2025-01-15 19:07:21 +00:00
const startChat = () => pushModal(ChatStart, {}, {replaceState: true})
const markAsRead = () => {
setChecked("/chat/*")
history.back()
}
2026-01-28 22:08:15 +00:00
const enableAlerts = () => notificationSettings.update(assoc("messages", true))
2026-01-28 22:08:15 +00:00
const disableAlerts = () => notificationSettings.update(assoc("messages", false))
2025-01-15 19:07:21 +00:00
</script>
2026-02-07 00:27:57 +00:00
<Modal>
<ModalBody>
2026-02-10 19:39:29 +00:00
<div class="flex flex-col gap-2">
<Button class="btn btn-primary" onclick={startChat}>
<Icon size={5} icon={ChatSquare} />
Start chat
2026-02-07 00:27:57 +00:00
</Button>
2026-02-10 19:39:29 +00:00
<Button class="btn btn-neutral" onclick={markAsRead}>
<Icon size={5} icon={Check} />
Mark all read
2026-02-07 00:27:57 +00:00
</Button>
2026-02-10 19:39:29 +00:00
{#if $notificationSettings.messages}
<Button class="btn btn-neutral" onclick={disableAlerts}>
<Icon size={4} icon={BellOff} />
Disable alerts
</Button>
{:else}
<Button class="btn btn-neutral" onclick={enableAlerts}>
<Icon size={4} icon={Bell} />
Enable alerts
</Button>
{/if}
</div>
2026-02-07 00:27:57 +00:00
</ModalBody>
</Modal>