design: impr message system and add marking as read

This commit is contained in:
Xylight committed 2025-11-11 18:45:53 -08:00
1 parent 662c35c499
commit 1c75a5248e
7 files changed
+88 -88

No files matched your search

+1 -1
View File
@@ -316,7 +316,7 @@
},
"postRedirect": {
"title": "Cross-server content",
"description": "That content does not originate from {{homeInstance}}. You can load it on your instance here.",
"description": "That content does not originate from {{homeInstance}}.",
"actions": {
"back": "Go back",
"fetch": "Locate post on {{homeInstance}}",
+26 -24
View File
@@ -222,28 +222,30 @@
</MenuButton>
</Menu>
<Menu placement="bottom-end">
{#snippet target(popover)}
<Button
{@attach popover}
title={$t('post.actions.more.label')}
color="ghost"
rounding="pill"
size="custom"
class={buttonSquare}
icon={EllipsisHorizontal}
></Button>
{/snippet}
{#snippet children(open)}
{#if open}
{#await import('./PostActionsMenu.svelte')}
<div class="p-8 w-full h-full grid place-items-center">
<Spinner width={20} />
</div>
{:then { default: PostActionsMenu }}
<PostActionsMenu bind:post {onhide} bind:editing />
{/await}
{/if}
{/snippet}
</Menu>
{#if profile.current.jwt}
<Menu placement="bottom-end">
{#snippet target(popover)}
<Button
{@attach popover}
title={$t('post.actions.more.label')}
color="ghost"
rounding="pill"
size="custom"
class={buttonSquare}
icon={EllipsisHorizontal}
></Button>
{/snippet}
{#snippet children(open)}
{#if open}
{#await import('./PostActionsMenu.svelte')}
<div class="p-8 w-full h-full grid place-items-center">
<Spinner width={20} />
</div>
{:then { default: PostActionsMenu }}
<PostActionsMenu bind:post {onhide} bind:editing />
{/await}
{/if}
{/snippet}
</Menu>
{/if}
</footer>
-1
View File
@@ -45,7 +45,6 @@
></TextInput>
{/if}
<Select
selectClass="h-[38px]"
baseClass="flex-1"
label={$t('form.time.duration')}
bind:value={duration}
@@ -43,6 +43,11 @@
none: '',
}
const interactiveClass = {
interactive: 'material-int',
none: '',
}
interface Props extends HTMLAttributes<HTMLElement> {
elevation?: Elevation
padding?: Padding
+34 -54
View File
@@ -57,6 +57,38 @@
}
</script>
{#snippet actions()}
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
disabled={loading ||
item.creator.id == profile.current.user?.local_user_view.person.id}
onclick={(e) => {
e.stopPropagation()
markAsRead(!item.read)
}}
size="sm"
rounding="pill"
class="shrink-0"
icon={item.read ? EyeSlash : Eye}
>
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
</Button>
<Button
href={item.type == 'private_message'
? `/inbox/messages/${item.item.private_message.creator_id}`
: `/comment/${item.item.comment.id}`}
size="sm"
rounding="pill"
class="shrink-0"
onclick={() => markAsRead(true)}
>
{$t('common.jump')}
</Button>
{/snippet}
<Expandable open icon={false}>
{#snippet title()}
<div class="flex flex-row gap-2 items-center w-full">
@@ -98,65 +130,13 @@
</div>
<div class="flex-1"></div>
<ButtonGroup orientation="horizontal" class="md:flex hidden shrink-0">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
disabled={loading}
onclick={(e) => {
e.stopPropagation()
markAsRead(!item.read)
}}
size="sm"
rounding="pill"
class="shrink-0"
icon={item.read ? EyeSlash : Eye}
>
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
</Button>
<Button
href={item.type == 'private_message'
? `/inbox/messages/${item.item.private_message.creator_id}`
: `/comment/${item.item.comment.id}`}
size="sm"
rounding="pill"
class="shrink-0"
onclick={() => markAsRead(true)}
>
{$t('common.jump')}
</Button>
{@render actions()}
</ButtonGroup>
</div>
{/snippet}
{#snippet extended()}
<ButtonGroup orientation="horizontal" class="flex md:hidden">
<Button
color={item.read ? 'secondary' : 'primary'}
{loading}
disabled={loading}
onclick={(e) => {
e.stopPropagation()
markAsRead(!item.read)
}}
size="sm"
rounding="pill"
icon={item.read ? EyeSlash : Eye}
>
{item.read
? $t('post.actions.more.markUnread')
: $t('post.actions.more.markRead')}
</Button>
<Button
href={item.type == 'private_message'
? `/inbox/messages/${item.item.private_message.creator_id}`
: `/comment/${item.item.comment.id}`}
size="sm"
rounding="pill"
onclick={() => markAsRead(true)}
>
{$t('common.jump')}
</Button>
{@render actions()}
</ButtonGroup>
{/snippet}
{#snippet content()}
@@ -2,6 +2,7 @@
import { browser } from '$app/environment'
import { client } from '$lib/api/client.svelte'
import type { PrivateMessageResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -88,6 +89,20 @@
let interval: number = -1
onMount(() => {
data.message.value.private_messages
.filter(
(i) =>
!i.private_message.read &&
i.private_message.creator_id !=
profile.current.user?.local_user_view.person.id,
)
.forEach((i) =>
client().markPrivateMessageAsRead({
private_message_id: i.private_message.id,
read: true,
}),
)
interval = setInterval(async () => {
const res = await client().getPrivateMessages({
creator_id: Number(data.creator.value.person_view.person.id),
@@ -95,7 +110,7 @@
page: 1,
})
data.message.value = res
}, 5 * 1000) as unknown as number
}, 15 * 1000) as unknown as number
return () => clearInterval(interval)
})
@@ -123,10 +138,10 @@
color="transparent"
rounding="2xl"
padding="none"
class="bg-white dark:bg-zinc-950 dark:border-t-zinc-900 w-full overflow-auto relative flex-1"
class="bg-white dark:bg-zinc-950 dark:border-t-zinc-900 w-full overflow-auto relative flex-1 min-h-0 max-h-[66vh] md:max-h-[64vh]"
>
<div class=" overflow-auto" bind:this={chatWindow}>
<ul id="chat-window" class=" flex flex-col gap-1 flex-1 px-4 py-4">
<div class="h-full overflow-auto max-w-full" bind:this={chatWindow}>
<ul id="chat-window" class=" flex flex-col gap-1 flex-1 px-4 py-4 min-h-0">
<div class="mt-auto"></div>
<p class="mx-auto mt-auto text-slate-400 dark:text-zinc-600 text-center">
{$t('routes.inbox.messages.conversation', {
+3 -4
View File
@@ -97,9 +97,8 @@
size="square-lg"
rounding="2xl"
icon={ShieldCheck}
>
{$t('moderation.label')}
</Button>
aria-label={$t('moderation.label')}
></Button>
{/snippet}
<MenuButton
href="/modlog?user={person.person.id}"
@@ -131,7 +130,7 @@
size="square-lg"
rounding="2xl"
icon={EllipsisHorizontal}
aria-label={$t('post.actions.more')}
aria-label={$t('post.actions.more.label')}
/>
{/snippet}
<MenuButton