diff options
| author | Kit La Touche <kit@transneptune.net> | 2025-11-30 22:59:21 -0500 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2025-11-30 22:59:21 -0500 |
| commit | 663dcb13a5b5085b58ebb10ee5f5eff4bb3d07ce (patch) | |
| tree | 957e310b190e5454bfc3301481bb6ff2a8def539 /ui/lib/components | |
| parent | 91c33501a315abe04aeed54aa27388ce0ad241ce (diff) | |
Show number of unread conversations in app badgenotifs-controls
Diffstat (limited to 'ui/lib/components')
| -rw-r--r-- | ui/lib/components/ChannelMeta.svelte | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ui/lib/components/ChannelMeta.svelte b/ui/lib/components/ChannelMeta.svelte new file mode 100644 index 0000000..2ee13b6 --- /dev/null +++ b/ui/lib/components/ChannelMeta.svelte @@ -0,0 +1,44 @@ +<script> + let { vapid, subscription, startExpanded = false, subscribe = async () => null } = $props(); + let pending = $state(false); + let expanded = $state(startExpanded); + + function onsubmit(callback) { + return async (evt) => { + evt.preventDefault(); + // Without this, the toggleExpanded function defined below will trigger: + evt.stopPropagation(); + + pending = true; + try { + // TODO: is this working? + await callback(); + } finally { + pending = false; + } + }; + } + + function toggleExpanded() { + // TODO: in messages.css we need to slide the whole div up, not leave its + // contents static. We need to show three little lines as a handle. We need + // to fix colours. We need to keep the meta consistently over the rest of + // the message list. We need to fix mobile click-area. Too easy to hit the + // title and go to / instead. + // Also: we can start expanded optionally, if there is a message we need to + // show. This can work for prompts like "activate your notifications". + expanded = !expanded; + } +</script> + +<div class="channel-meta {expanded ? 'expanded' : ''}" onclick={toggleExpanded}> + + <div class="inner"> + {#if !subscription} + <form class="form" onsubmit={onsubmit(subscribe)}> + <button disabled={pending} type="submit">create push subscription</button> + </form> + {/if} + </div> + <div class="handle">≡</div> +</div> |
