Tweak alerts button layout

This commit is contained in:
Jon Staab
2025-06-30 09:38:43 -07:00
parent b9620f4443
commit b9048936ba
2 changed files with 45 additions and 38 deletions

View File

@@ -41,6 +41,7 @@
notifyChat?: boolean notifyChat?: boolean
notifyThreads?: boolean notifyThreads?: boolean
notifyCalendar?: boolean notifyCalendar?: boolean
hideSpaceField?: boolean
} }
let { let {
@@ -49,6 +50,7 @@
notifyChat = true, notifyChat = true,
notifyThreads = true, notifyThreads = true,
notifyCalendar = true, notifyCalendar = true,
hideSpaceField = false,
}: Props = $props() }: Props = $props()
const timezoneOffset = parseInt(TIMEZONE.slice(3)) / 100 const timezoneOffset = parseInt(TIMEZONE.slice(3)) / 100
@@ -229,19 +231,21 @@
{/snippet} {/snippet}
</FieldInline> </FieldInline>
{/if} {/if}
<FieldInline> {#if !hideSpaceField}
{#snippet label()} <FieldInline>
<p>Space*</p> {#snippet label()}
{/snippet} <p>Space*</p>
{#snippet input()} {/snippet}
<select bind:value={relay} class="select select-bordered"> {#snippet input()}
<option value="" disabled selected>Choose a space URL</option> <select bind:value={relay} class="select select-bordered">
{#each getMembershipUrls($userMembership) as url (url)} <option value="" disabled selected>Choose a space URL</option>
<option value={url}>{displayRelayUrl(url)}</option> {#each getMembershipUrls($userMembership) as url (url)}
{/each} <option value={url}>{displayRelayUrl(url)}</option>
</select> {/each}
{/snippet} </select>
</FieldInline> {/snippet}
</FieldInline>
{/if}
<FieldInline> <FieldInline>
{#snippet label()} {#snippet label()}
<p>Notifications*</p> <p>Notifications*</p>

View File

@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import {onMount} from "svelte" import {onMount} from "svelte"
import {displayRelayUrl, getTagValue} from "@welshman/util" import {displayRelayUrl, getTagValue, MESSAGE, THREAD, EVENT_TIME} from "@welshman/util"
import {pubkey, deriveRelay} from "@welshman/app" import {pubkey, deriveRelay} from "@welshman/app"
import {fly} from "@lib/transition" import {fly} from "@lib/transition"
import Icon from "@lib/components/Icon.svelte" import Icon from "@lib/components/Icon.svelte"
@@ -14,7 +14,6 @@
import SpaceJoin from "@app/components/SpaceJoin.svelte" import SpaceJoin from "@app/components/SpaceJoin.svelte"
import ProfileList from "@app/components/ProfileList.svelte" import ProfileList from "@app/components/ProfileList.svelte"
import AlertAdd from "@app/components/AlertAdd.svelte" import AlertAdd from "@app/components/AlertAdd.svelte"
import AlertDelete from "@app/components/AlertDelete.svelte"
import RoomCreate from "@app/components/RoomCreate.svelte" import RoomCreate from "@app/components/RoomCreate.svelte"
import MenuSpaceRoomItem from "@app/components/MenuSpaceRoomItem.svelte" import MenuSpaceRoomItem from "@app/components/MenuSpaceRoomItem.svelte"
import InfoMissingRooms from "@app/components/InfoMissingRooms.svelte" import InfoMissingRooms from "@app/components/InfoMissingRooms.svelte"
@@ -40,7 +39,6 @@
const calendarPath = makeSpacePath(url, "calendar") const calendarPath = makeSpacePath(url, "calendar")
const userRooms = deriveUserRooms(url) const userRooms = deriveUserRooms(url)
const otherRooms = deriveOtherRooms(url) const otherRooms = deriveOtherRooms(url)
const alert = $derived($deviceAlerts.find(a => getTagValue("feed", a.tags)?.includes(url)))
const openMenu = () => { const openMenu = () => {
showMenu = true showMenu = true
@@ -67,9 +65,22 @@
const addRoom = () => pushModal(RoomCreate, {url}, {replaceState}) const addRoom = () => pushModal(RoomCreate, {url}, {replaceState})
const addAlert = () => pushModal(AlertAdd, {relay: url, channel: "push"}, {replaceState}) const addAlert = () => {
const alert = $deviceAlerts.find(a => getTagValue("feed", a.tags)?.includes(url))
const feed = getTagValue("feed", alert?.tags || [])
const deleteAlert = () => pushModal(AlertDelete, {alert}, {replaceState}) const props = {
relay: url,
channel: "push",
notifyChat: feed ? feed.includes(String(MESSAGE)) : true,
notifyThreads: feed ? feed.includes(String(THREAD)) : true,
notifyCalendar: feed ? feed.includes(String(EVENT_TIME)) : true,
removeDuplicates: true,
hideSpaceField: true,
}
pushModal(AlertAdd, props, {replaceState})
}
let showMenu = $state(false) let showMenu = $state(false)
let replaceState = $state(false) let replaceState = $state(false)
@@ -85,11 +96,13 @@
}) })
</script> </script>
<div bind:this={element}> <div bind:this={element} class="flex h-screen flex-col justify-between">
<SecondaryNavSection class="max-h-screen"> <SecondaryNavSection>
<div> <div>
<SecondaryNavItem class="w-full !justify-between" onclick={openMenu}> <SecondaryNavItem class="w-full !justify-between" onclick={openMenu}>
<strong class="ellipsize">{displayRelayUrl(url)}</strong> <strong class="ellipsize flex items-center gap-3">
{displayRelayUrl(url)}
</strong>
<Icon icon="alt-arrow-down" /> <Icon icon="alt-arrow-down" />
</SecondaryNavItem> </SecondaryNavItem>
{#if showMenu} {#if showMenu}
@@ -109,21 +122,6 @@
Create Invite Create Invite
</Button> </Button>
</li> </li>
{#if alert}
<li>
<Button onclick={deleteAlert}>
<Icon icon="bell" />
Disable alerts
</Button>
</li>
{:else}
<li>
<Button onclick={addAlert}>
<Icon icon="bell" />
Enable alerts
</Button>
</li>
{/if}
<li> <li>
{#if $userRoomsByUrl.has(url)} {#if $userRoomsByUrl.has(url)}
<Button onclick={leaveSpace} class="text-error"> <Button onclick={leaveSpace} class="text-error">
@@ -194,6 +192,11 @@
Where did my rooms go? Where did my rooms go?
</Button> </Button>
{/if} {/if}
</div> </div></SecondaryNavSection>
</SecondaryNavSection> <div class="p-4">
<button class="btn btn-neutral btn-sm w-full" onclick={addAlert}>
<Icon icon="bell" />
Manage Alerts
</button>
</div>
</div> </div>