Merge pull request #667 from Xyphyn/impr/inbox-mark-read
Impr: auto mark inbox items as read when clicked
This commit is contained in:
19 files changed
+158
-56
No files matched your search
@@ -303,7 +303,7 @@
|
||||
"localView": "Local View",
|
||||
"thread": {
|
||||
"single": "You're viewing a single thread.",
|
||||
"allComments": "All Comments",
|
||||
"allComments": "All comments",
|
||||
"part": "You're viewing part of a thread.",
|
||||
"context": "Show Context"
|
||||
},
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { Post } from "$lib/api/types"
|
||||
import VirtualList from "$lib/app/render/VirtualList.svelte"
|
||||
import { onMount } from "svelte"
|
||||
import type { CommentNodeI } from "./comments.svelte"
|
||||
import CommentTree from "./CommentTree.svelte"
|
||||
import type { Post } from '$lib/api/types'
|
||||
import VirtualList from '$lib/app/render/VirtualList.svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { fly } from 'svelte/transition'
|
||||
import type { CommentNodeI } from './comments.svelte'
|
||||
import CommentTree from './CommentTree.svelte'
|
||||
|
||||
interface Props {
|
||||
nodes: CommentNodeI[]
|
||||
@@ -47,10 +49,15 @@
|
||||
items={nodes}
|
||||
{initialOffset}
|
||||
>
|
||||
{#snippet item(index)}
|
||||
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
||||
{#snippet item(row)}
|
||||
<div
|
||||
in:fly={row < 7
|
||||
? { duration: 800, easing: expoOut, y: 12, delay: row * 50 }
|
||||
: { opacity: 1, duration: 0 }}
|
||||
class="px-3 sm:px-6"
|
||||
>
|
||||
<CommentTree
|
||||
bind:nodes={() => [nodes[index]], (v) => (nodes[index] = v[0])}
|
||||
bind:nodes={() => [nodes[row]], (v) => (nodes[row] = v[0])}
|
||||
{post}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<ul class="animate-pop-in">
|
||||
<ul>
|
||||
{#each nodes as node, index (node.comment_view.comment.id)}
|
||||
<Comment
|
||||
bind:node={nodes[index]}
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<button
|
||||
onclick={() => castVote(vote == targetNum ? 0 : targetNum)}
|
||||
class={[
|
||||
'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2',
|
||||
'flex items-center gap-0.5 transition-colors relative cursor-pointer h-full p-2 active:brightness-90',
|
||||
'first:rounded-l-3xl last:rounded-r-3xl',
|
||||
'last:flex-row-reverse',
|
||||
vote == targetNum
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
>
|
||||
<Avatar url={icon} alt={title} width={detail ? 32 : 24} circle={false} />
|
||||
<a class="flex-1 flex flex-col group" {href}>
|
||||
<h3
|
||||
class="font-medium text-base overflow-hidden text-ellipsis leading-5 group-hover:underline"
|
||||
>
|
||||
<h3 class="font-medium text-base overflow-hidden text-ellipsis leading-5">
|
||||
{title}
|
||||
</h3>
|
||||
<p class="text-sm text-slate-600 dark:text-zinc-400">
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
transition: background-color 0.1s;
|
||||
background-color: var(--color-white);
|
||||
container-type: inline-size;
|
||||
border: 1px solid var(--color-slate-100);
|
||||
|
||||
border-radius: var(--radius-md) var(--radius-md);
|
||||
|
||||
@@ -103,6 +104,7 @@
|
||||
}
|
||||
|
||||
:global(.dark) ul > :global(li) {
|
||||
border: 1px solid var(--color-zinc-900);
|
||||
background-color: color-mix(
|
||||
in oklab,
|
||||
var(--color-zinc-925),
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
class={[
|
||||
'rounded-full font-medium transition-colors duration-100 relative z-0 shrink-0 hover:text-slate-900 hover:dark:text-zinc-100',
|
||||
selected
|
||||
? 'text-primary-900 dark:text-primary-100'
|
||||
? 'tab-selected text-primary-900 dark:text-primary-100 hover:cursor-default'
|
||||
: 'text-slate-500 dark:text-zinc-500',
|
||||
]}
|
||||
>
|
||||
@@ -90,3 +90,17 @@
|
||||
{/each}
|
||||
{@render children?.()}
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
.tab-selected {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-selected::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: calc(var(--spacing) * -1) calc(var(--spacing) * -3);
|
||||
z-index: -10;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
</style>
|
||||
@@ -71,7 +71,7 @@
|
||||
:global {
|
||||
.prefix {
|
||||
@variant max-md {
|
||||
height: 100%;
|
||||
height: 90%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
aspect-ratio: 1 / 1;
|
||||
@@ -119,12 +119,18 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@variant hover {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
@variant max-md {
|
||||
.nav-btn-sm-primary .prefix {
|
||||
.nav-btn-sm-primary .prefix {
|
||||
@variant max-md {
|
||||
background-color: var(--color-primary-900);
|
||||
color: var(--color-slate-50);
|
||||
border-radius: var(--radius-xl);
|
||||
height: 80%;
|
||||
|
||||
@variant hover {
|
||||
color: var(--color-slate-50);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
icon={Home}
|
||||
href="/"
|
||||
label={$t('nav.home')}
|
||||
class="logo border-0 md:rounded-full! md:w-10! md:h-10 md:px-0! text-primary-900! dark:text-primary-100! -order-1"
|
||||
class="logo border-0 md:rounded-full! md:w-10! md:h-10 md:px-0! -order-1"
|
||||
adaptive={false}
|
||||
>
|
||||
{#snippet customIcon()}
|
||||
@@ -64,7 +64,14 @@
|
||||
<Spinner width={32} />
|
||||
{/if}
|
||||
{:else}
|
||||
<Logo width={32} />
|
||||
<div class="hidden md:block text-primary-900! dark:text-primary-100!">
|
||||
<Logo width={32} />
|
||||
</div>
|
||||
<div class={['block md:hidden text-inherit!']}>
|
||||
<div class="prefix">
|
||||
<Icon src={Home} size="20" mini />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</NavButton>
|
||||
|
||||
@@ -179,6 +179,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.no-hover:hover {
|
||||
cursor: normal !important;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
border: 1px solid transparent;
|
||||
background-color: var(--color-primary-900);
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte'
|
||||
|
||||
interface Props {
|
||||
orientation: 'horizontal'
|
||||
class?: string
|
||||
children?: Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
orientation = 'horizontal',
|
||||
children,
|
||||
class: clazz,
|
||||
...rest
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
{...rest}
|
||||
role="group"
|
||||
class={[
|
||||
'btn-group',
|
||||
orientation == 'horizontal' ? 'btn-group-horizontal' : 'btn-group-vertical',
|
||||
clazz,
|
||||
]}
|
||||
>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.btn-group {
|
||||
gap: var(--spacing);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.btn-group.btn-group-horizontal {
|
||||
flex-direction: row;
|
||||
|
||||
:global(*) {
|
||||
position: relative;
|
||||
&:first-child {
|
||||
border-radius: 24px 8px 8px 24px !important;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-radius: 8px 24px 24px 8px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+17
-12
@@ -1,33 +1,38 @@
|
||||
// Reexport your entry components here
|
||||
|
||||
export { default as Button } from './button/Button.svelte'
|
||||
export { buttonColor, buttonSize, buttonShadow } from './button/Button.svelte'
|
||||
export {
|
||||
default as Button,
|
||||
buttonColor,
|
||||
buttonShadow,
|
||||
buttonSize,
|
||||
} from './button/Button.svelte'
|
||||
export { default as ButtonGroup } from './button/ButtonGroup.svelte'
|
||||
export { default as Spinner } from './loader/Spinner.svelte'
|
||||
export { default as TextLoader } from './loader/TextLoader.svelte'
|
||||
export { default as Material } from './materials/Material.svelte'
|
||||
|
||||
export { default as Label } from './forms/Label.svelte'
|
||||
export { default as FileInput } from './forms/FileInput.svelte'
|
||||
export { default as TextInput } from './forms/TextInput.svelte'
|
||||
export { default as Label } from './forms/Label.svelte'
|
||||
export { default as TextArea } from './forms/TextArea.svelte'
|
||||
export { default as Select } from './forms/select/Select.svelte'
|
||||
export { default as TextInput } from './forms/TextInput.svelte'
|
||||
export { default as Option } from './forms/select/Option.svelte'
|
||||
export { default as Select } from './forms/select/Select.svelte'
|
||||
|
||||
export { default as Switch } from './forms/Switch.svelte'
|
||||
|
||||
export { default as Popover } from './popover/Popover.svelte'
|
||||
export { default as Menu } from './popover/Menu.svelte'
|
||||
export { default as MenuDivider } from './popover/MenuDivider.svelte'
|
||||
export { default as MenuButton } from './popover/MenuButton.svelte'
|
||||
export { default as Disclosure } from './disclosure/Disclosure.svelte'
|
||||
export { default as Expandable } from './disclosure/Expandable.svelte'
|
||||
export { default as Modal } from './modal/Modal.svelte'
|
||||
export { modal, action } from './modal/modal.js'
|
||||
export { default as ModalContainer } from './modal/ModalContainer.svelte'
|
||||
export { action, modal } from './modal/modal.js'
|
||||
export { default as Menu } from './popover/Menu.svelte'
|
||||
export { default as MenuButton } from './popover/MenuButton.svelte'
|
||||
export { default as MenuDivider } from './popover/MenuDivider.svelte'
|
||||
export { default as Popover } from './popover/Popover.svelte'
|
||||
|
||||
export { toast, removeToast, toasts, toastColors } from './toast/toasts.js'
|
||||
export { default as ToastContainer } from './toast/ToastContainer.svelte'
|
||||
export { removeToast, toast, toastColors, toasts } from './toast/toasts.js'
|
||||
|
||||
export { default as Note } from './note/Note.svelte'
|
||||
export { default as Badge } from './badge/Badge.svelte'
|
||||
export { default as Note } from './note/Note.svelte'
|
||||
export { default as Search } from './search/Search.svelte'
|
||||
@@ -5,7 +5,7 @@
|
||||
import Portal from 'mono-svelte/popover/Portal.svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
import { XMark } from 'svelte-hero-icons/dist'
|
||||
import { backOut } from 'svelte/easing'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import type { ClassValue } from 'svelte/elements'
|
||||
import { fade, scale } from 'svelte/transition'
|
||||
import { trapFocus } from 'trap-focus-svelte'
|
||||
@@ -97,7 +97,7 @@
|
||||
use:trapFocus={true}
|
||||
transition:scale|global={{
|
||||
start: 0.97,
|
||||
easing: backOut,
|
||||
easing: expoOut,
|
||||
duration: 300,
|
||||
}}
|
||||
class={[
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
let selected = $derived(page.url.pathname == href)
|
||||
let selected = $derived(page.url.pathname.startsWith(href))
|
||||
</script>
|
||||
|
||||
<Button
|
||||
@@ -36,7 +36,7 @@
|
||||
class={[
|
||||
'hover:text-slate-900 hover:dark:text-zinc-50',
|
||||
selected
|
||||
? 'text-primary-900 dark:text-primary-100'
|
||||
? 'text-primary-900 dark:text-primary-100 cursor-default!'
|
||||
: 'text-slate-600 dark:text-zinc-400',
|
||||
clazz,
|
||||
]}
|
||||
|
||||
@@ -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)}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
PostMeta,
|
||||
type Tag,
|
||||
} from '$lib/feature/post'
|
||||
import Fixate from '$lib/ui/generic/Fixate.svelte'
|
||||
import Placeholder from '$lib/ui/info/Placeholder.svelte'
|
||||
import { CommonList } from '$lib/ui/layout'
|
||||
import EndPlaceholder from '$lib/ui/layout/EndPlaceholder.svelte'
|
||||
@@ -214,13 +215,9 @@
|
||||
</article>
|
||||
{#await data.data.value.comments then comments}
|
||||
{#if data.data.value.params.thread.showContext || data.data.value.params.thread.singleThread}
|
||||
<div
|
||||
class="sticky mx-auto z-50 max-w-md min-w-0 flex flex-col items-center overflow-auto gap-1
|
||||
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-200/50 dark:border-zinc-800/50
|
||||
p-1 rounded-full justify-between top-6 lg:top-22 my-4"
|
||||
>
|
||||
<Fixate placement="top">
|
||||
<Button
|
||||
color="none"
|
||||
color="primary"
|
||||
rounding="pill"
|
||||
{loading}
|
||||
disabled={loading}
|
||||
@@ -232,7 +229,7 @@
|
||||
: data.data.value.params.thread.singleThread
|
||||
? postLink(data.data.value.post.post)
|
||||
: undefined}
|
||||
class="hover:bg-white/50 dark:hover:bg-zinc-800/30"
|
||||
class="w-max mx-auto sticky lg:top-20 z-50"
|
||||
>
|
||||
{data.data.value.params.thread.showContext
|
||||
? $t('routes.post.thread.context')
|
||||
@@ -241,7 +238,7 @@
|
||||
<Icon src={ArrowRight} size="16" micro />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</div>
|
||||
</Fixate>
|
||||
{/if}
|
||||
{/await}
|
||||
<section class="flex flex-col gap-2 w-full" id="comments">
|
||||
|
||||
Reference in new issue
Block a user