feat: Add private messages

This commit is contained in:
Xyphyn committed 2023-07-06 11:54:53 -07:00
1 parent 1a0881f9ce
commit 7113dc8463
9 files changed
+176 -46

No files matched your search

+16 -5
View File
@@ -1,18 +1,23 @@
<script lang="ts">
import type { CommentReplyView, PersonMentionView } from 'lemmy-js-client'
import type {
CommentReplyView,
PersonMentionView,
PrivateMessageView,
} from 'lemmy-js-client'
import InboxItem from './InboxItem.svelte'
import Button from '$lib/components/input/Button.svelte'
import { Check, Icon } from 'svelte-hero-icons'
import { authData, getClient } from '$lib/lemmy.js'
import { authData, getClient, user } from '$lib/lemmy.js'
import { goto } from '$app/navigation'
import { page } from '$app/stores'
export let data: {
data: PersonMentionView[] | CommentReplyView[]
data: PersonMentionView[] | CommentReplyView[] | PrivateMessageView[]
}
function isRead(item: PersonMentionView | CommentReplyView) {
console.log('running...')
function isRead(
item: PersonMentionView | CommentReplyView | PrivateMessageView
) {
if ('person_mention' in item) {
return (item as PersonMentionView).person_mention.read
}
@@ -21,6 +26,10 @@
return (item as CommentReplyView).comment_reply.read
}
if ('private_message' in item) {
return (item as PrivateMessageView).private_message.read
}
return false
}
@@ -29,6 +38,8 @@
auth: $authData!.token,
})
$user.unreads = 0
goto($page.url, {
invalidateAll: true,
})