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
+64 -64

No files matched your search

+1 -1
View File
@@ -316,7 +316,7 @@
}, },
"postRedirect": { "postRedirect": {
"title": "Cross-server content", "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": { "actions": {
"back": "Go back", "back": "Go back",
"fetch": "Locate post on {{homeInstance}}", "fetch": "Locate post on {{homeInstance}}",
@@ -222,6 +222,7 @@
</MenuButton> </MenuButton>
</Menu> </Menu>
{#if profile.current.jwt}
<Menu placement="bottom-end"> <Menu placement="bottom-end">
{#snippet target(popover)} {#snippet target(popover)}
<Button <Button
@@ -246,4 +247,5 @@
{/if} {/if}
{/snippet} {/snippet}
</Menu> </Menu>
{/if}
</footer> </footer>
-1
View File
@@ -45,7 +45,6 @@
></TextInput> ></TextInput>
{/if} {/if}
<Select <Select
selectClass="h-[38px]"
baseClass="flex-1" baseClass="flex-1"
label={$t('form.time.duration')} label={$t('form.time.duration')}
bind:value={duration} bind:value={duration}
@@ -43,6 +43,11 @@
none: '', none: '',
} }
const interactiveClass = {
interactive: 'material-int',
none: '',
}
interface Props extends HTMLAttributes<HTMLElement> { interface Props extends HTMLAttributes<HTMLElement> {
elevation?: Elevation elevation?: Elevation
padding?: Padding padding?: Padding
+34 -54
View File
@@ -57,6 +57,38 @@
} }
</script> </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}> <Expandable open icon={false}>
{#snippet title()} {#snippet title()}
<div class="flex flex-row gap-2 items-center w-full"> <div class="flex flex-row gap-2 items-center w-full">
@@ -98,65 +130,13 @@
</div> </div>
<div class="flex-1"></div> <div class="flex-1"></div>
<ButtonGroup orientation="horizontal" class="md:flex hidden shrink-0"> <ButtonGroup orientation="horizontal" class="md:flex hidden shrink-0">
<Button {@render actions()}
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>
</ButtonGroup> </ButtonGroup>
</div> </div>
{/snippet} {/snippet}
{#snippet extended()} {#snippet extended()}
<ButtonGroup orientation="horizontal" class="flex md:hidden"> <ButtonGroup orientation="horizontal" class="flex md:hidden">
<Button {@render actions()}
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>
</ButtonGroup> </ButtonGroup>
{/snippet} {/snippet}
{#snippet content()} {#snippet content()}
@@ -2,6 +2,7 @@
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { client } from '$lib/api/client.svelte' import { client } from '$lib/api/client.svelte'
import type { PrivateMessageResponse } from '$lib/api/types' import type { PrivateMessageResponse } from '$lib/api/types'
import { profile } from '$lib/app/auth.svelte'
import { errorMessage } from '$lib/app/error' import { errorMessage } from '$lib/app/error'
import { t } from '$lib/app/i18n' import { t } from '$lib/app/i18n'
import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte' import MarkdownEditor from '$lib/app/markdown/MarkdownEditor.svelte'
@@ -88,6 +89,20 @@
let interval: number = -1 let interval: number = -1
onMount(() => { 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 () => { interval = setInterval(async () => {
const res = await client().getPrivateMessages({ const res = await client().getPrivateMessages({
creator_id: Number(data.creator.value.person_view.person.id), creator_id: Number(data.creator.value.person_view.person.id),
@@ -95,7 +110,7 @@
page: 1, page: 1,
}) })
data.message.value = res data.message.value = res
}, 5 * 1000) as unknown as number }, 15 * 1000) as unknown as number
return () => clearInterval(interval) return () => clearInterval(interval)
}) })
@@ -123,10 +138,10 @@
color="transparent" color="transparent"
rounding="2xl" rounding="2xl"
padding="none" 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}> <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"> <ul id="chat-window" class=" flex flex-col gap-1 flex-1 px-4 py-4 min-h-0">
<div class="mt-auto"></div> <div class="mt-auto"></div>
<p class="mx-auto mt-auto text-slate-400 dark:text-zinc-600 text-center"> <p class="mx-auto mt-auto text-slate-400 dark:text-zinc-600 text-center">
{$t('routes.inbox.messages.conversation', { {$t('routes.inbox.messages.conversation', {
+3 -4
View File
@@ -97,9 +97,8 @@
size="square-lg" size="square-lg"
rounding="2xl" rounding="2xl"
icon={ShieldCheck} icon={ShieldCheck}
> aria-label={$t('moderation.label')}
{$t('moderation.label')} ></Button>
</Button>
{/snippet} {/snippet}
<MenuButton <MenuButton
href="/modlog?user={person.person.id}" href="/modlog?user={person.person.id}"
@@ -131,7 +130,7 @@
size="square-lg" size="square-lg"
rounding="2xl" rounding="2xl"
icon={EllipsisHorizontal} icon={EllipsisHorizontal}
aria-label={$t('post.actions.more')} aria-label={$t('post.actions.more.label')}
/> />
{/snippet} {/snippet}
<MenuButton <MenuButton