i forgot whatever i've been doing, i think i added an inbox
This commit is contained in:
1 parent
ef037349f0
commit
04704749b7
24 files changed
+307
-86
No files matched your search
@@ -0,0 +1,18 @@
|
||||
<script lang="ts">
|
||||
import InboxItem from './InboxItem.svelte'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
|
||||
<h1 class="font-bold text-3xl">Inbox</h1>
|
||||
<div class="flex flex-col gap-4 list-none my-4">
|
||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||
<p class="text-center opacity-60 text-lg mx-4">
|
||||
Wow, it's quite empty in here.
|
||||
</p>
|
||||
{:else}
|
||||
{#each data.data as item}
|
||||
<InboxItem {item} />
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getInboxItemPublished } from '$lib/lemmy/inbox.js'
|
||||
import { get } from 'svelte/store'
|
||||
|
||||
export async function load() {
|
||||
const auth = get(authData)
|
||||
if (!auth) return
|
||||
|
||||
const client = getClient()
|
||||
|
||||
const params = {
|
||||
limit: 50,
|
||||
page: 1,
|
||||
auth: auth.token,
|
||||
}
|
||||
|
||||
const [replies, mentions, privateMessages] = await Promise.all([
|
||||
client.getReplies({
|
||||
...params,
|
||||
sort: 'New',
|
||||
}),
|
||||
client.getPersonMentions({
|
||||
...params,
|
||||
sort: 'New',
|
||||
}),
|
||||
client.getPrivateMessages(params),
|
||||
])
|
||||
|
||||
const data = [...replies.replies, ...mentions.mentions].sort(
|
||||
(a, b) =>
|
||||
Date.parse(getInboxItemPublished(b)) -
|
||||
Date.parse(getInboxItemPublished(a))
|
||||
)
|
||||
|
||||
return { data: data }
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
import Link from '$lib/components/input/Link.svelte'
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import Card from '$lib/components/ui/Card.svelte'
|
||||
import type { CommentReplyView, PersonMentionView } from 'lemmy-js-client'
|
||||
|
||||
export let item: CommentReplyView | PersonMentionView
|
||||
</script>
|
||||
|
||||
<Card class="flex flex-col bg-white rounded-md p-4 max-w-full">
|
||||
<div class="flex flex-row items-center">
|
||||
<div
|
||||
class="text-sm max-w-[80ch] whitespace-nowrap text-ellipsis overflow-hidden"
|
||||
>
|
||||
<span class="font-bold">
|
||||
{item.creator.display_name ?? item.creator.name}
|
||||
</span>
|
||||
replied to you in
|
||||
<a
|
||||
href="/post/{item.post.id}"
|
||||
class="font-bold max-w-[48ch] overflow-hidden text-ellipsis
|
||||
whitespace-nowrap inline hover:underline"
|
||||
>
|
||||
{item.post.name}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="w-max ml-auto">
|
||||
<Link href="/post/{item.post.id}#{item.comment.id}">Jump</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Comment
|
||||
postId={item.post.id}
|
||||
node={{ children: [], comment_view: item, depth: 1 }}
|
||||
replying={false}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
Reference in new issue
Block a user