impr: automatically mark as read inbox items when clicked

This commit is contained in:
Xylight committed 2025-10-06 19:20:59 -07:00
1 parent 75aa414c3b
commit c73cce8f8a
7 files changed
+93 -26

No files matched your search

+11 -4
View File
@@ -102,10 +102,17 @@
class="self-center justify-self-center my-auto"
/>
{:else}
<CommonList items={data.inbox.value} size="md">
{#snippet item(item)}
<InboxItem {item} />
{/snippet}
<CommonList size="md">
{#each data.inbox.value as item}
<li
class={[
'lg:px-2.5 lg:py-1.5',
!item.read && 'bg-blue-300/10! dark:bg-blue-500/5!',
]}
>
<InboxItem {item} />
</li>
{/each}
</CommonList>
{/if}
{#if !(data.page == 1 && (data?.inbox?.value.length ?? 0) == 0)}
+1 -1
View File
@@ -19,7 +19,7 @@ export async function load({ url, fetch }) {
const client = getClient(undefined, fetch)
const page = Number(url.searchParams.get('page')) || 1
const unreadOnly: boolean =
(url.searchParams.get('unreadOnly') || 'true') == 'true'
(url.searchParams.get('unreadOnly') || 'false') == 'true'
const params = {
limit: 20,
+8 -6
View File
@@ -9,7 +9,7 @@
import PrivateMessage from '$lib/feature/inbox/PrivateMessage.svelte'
import Avatar from '$lib/ui/generic/Avatar.svelte'
import { publishedToDate } from '$lib/ui/util/date'
import { Button, Expandable } from 'mono-svelte'
import { Button, ButtonGroup, Expandable } from 'mono-svelte'
import RelativeDate from 'mono-svelte/util/RelativeDate.svelte'
import { Eye, EyeSlash } from 'svelte-hero-icons/dist'
@@ -22,7 +22,7 @@
let loading = $state(false)
async function markAsRead(isRead: boolean) {
if (!profile.current?.jwt) return
if (isRead && item.read) return
loading = true
@@ -96,7 +96,7 @@
</div>
</div>
<div class="flex-1"></div>
<div class="flex gap-2 max-md:hidden shrink-0">
<ButtonGroup orientation="horizontal" class="md:flex hidden shrink-0">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
@@ -121,14 +121,15 @@
size="sm"
rounding="pill"
class="shrink-0"
onclick={() => markAsRead(true)}
>
{$t('common.jump')}
</Button>
</div>
</ButtonGroup>
</div>
{/snippet}
{#snippet extended()}
<div class="flex gap-2 w-full md:hidden mt-1 flex-wrap">
<ButtonGroup orientation="horizontal" class="flex md:hidden">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
@@ -151,10 +152,11 @@
: `/comment/${item.item.comment.id}`}
size="sm"
rounding="pill"
onclick={() => markAsRead(true)}
>
{$t('common.jump')}
</Button>
</div>
</ButtonGroup>
{/snippet}
{#snippet content()}
{#if item.type == 'comment_reply' || item.type == 'person_mention'}
+4 -1
View File
@@ -137,7 +137,10 @@
{/if}
<CommonList items={previews}>
{#snippet item(preview)}
<a href="/inbox/messages/{preview.user.id}" class="flex flex-row gap-2">
<a
href="/inbox/messages/{preview.user.id}"
class="flex flex-row items-center gap-2"
>
<Avatar url={preview.user.avatar} alt={preview.user.name} width={32} />
<div class="flex flex-col w-full overflow-hidden">
<div class="font-medium">{preview.user.name}</div>