feat: add new messages ui
This commit is contained in:
1 parent
ffdcac6c79
commit
a77b3b3b78
10 files changed
+409
-23
No files matched your search
@@ -3,22 +3,34 @@
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import type {
|
||||
CommentView,
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
} from 'lemmy-js-client'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { Button, Modal } from 'mono-svelte'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import PrivateMessage from '../inbox/PrivateMessage.svelte'
|
||||
|
||||
export let open: boolean
|
||||
export let item: PostView | CommentView | undefined = undefined
|
||||
export let item: PostView | CommentView | PrivateMessageView | undefined =
|
||||
undefined
|
||||
|
||||
const isComment = (item: PostView | CommentView): item is CommentView =>
|
||||
'comment' in item
|
||||
const isComment = (
|
||||
item: PostView | CommentView | PrivateMessageView
|
||||
): item is CommentView => 'comment' in item
|
||||
|
||||
const isPost = (item: PostView | CommentView): item is PostView =>
|
||||
!isComment(item)
|
||||
const isPost = (
|
||||
item: PostView | CommentView | PrivateMessageView
|
||||
): item is PostView => !isComment(item) && 'post' in item
|
||||
|
||||
const isPrivateMessage = (
|
||||
item: PostView | CommentView | PrivateMessageView
|
||||
): item is PrivateMessageView => !isComment(item) && 'private_message' in item
|
||||
|
||||
let loading = false
|
||||
let reason = ''
|
||||
@@ -38,6 +50,11 @@
|
||||
post_id: item.post.id,
|
||||
reason: reason,
|
||||
})
|
||||
} else if (isPrivateMessage(item)) {
|
||||
await getClient().createPrivateMessageReport({
|
||||
private_message_id: item.private_message.id,
|
||||
reason: reason,
|
||||
})
|
||||
}
|
||||
open = false
|
||||
toast({
|
||||
@@ -77,6 +94,8 @@
|
||||
/>
|
||||
{:else if isPost(item)}
|
||||
<Post actions={false} post={item} />
|
||||
{:else}
|
||||
<PrivateMessage message={item} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import { client } from '$lib/lemmy'
|
||||
import type { SubmissionView } from '$lib/lemmy/contentview.js'
|
||||
import type { Comment, Community, MyUserInfo, Person } from 'lemmy-js-client'
|
||||
import type {
|
||||
Comment,
|
||||
CommentView,
|
||||
Community,
|
||||
MyUserInfo,
|
||||
Person,
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
} from 'lemmy-js-client'
|
||||
import { get, writable } from 'svelte/store'
|
||||
|
||||
interface Modals {
|
||||
reporting: {
|
||||
open: boolean
|
||||
item: SubmissionView | undefined
|
||||
item: PostView | CommentView | PrivateMessageView | undefined
|
||||
}
|
||||
removing: {
|
||||
open: boolean
|
||||
@@ -39,7 +47,7 @@ export let modals = writable<Modals>({
|
||||
},
|
||||
})
|
||||
|
||||
export function report(item: SubmissionView) {
|
||||
export function report(item: PostView | CommentView | PrivateMessageView) {
|
||||
modals.update((m) => ({
|
||||
...m,
|
||||
reporting: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
@@ -6,6 +7,7 @@
|
||||
href: string
|
||||
name: string
|
||||
}[]
|
||||
export let currentRoute: string | undefined = undefined
|
||||
</script>
|
||||
|
||||
<nav
|
||||
@@ -16,12 +18,13 @@
|
||||
>
|
||||
{#each routes as route}
|
||||
<a
|
||||
on:click={() => invalidate(route.href)}
|
||||
href={route.href}
|
||||
class="font-medium rounded-full px-4 py-1 hover:bg-slate-200/40 hover:dark:bg-zinc-700/40
|
||||
transition-colors duration-100 relative z-0"
|
||||
>
|
||||
{route.name}
|
||||
{#if $page.url.pathname == route.href}
|
||||
{#if (currentRoute ?? $page.url.pathname) == route.href}
|
||||
<div
|
||||
class="rounded-full bg-slate-100/60 dark:bg-zinc-700/60
|
||||
absolute inset-0 w-full h-full -z-10"
|
||||
|
||||
@@ -46,6 +46,7 @@ export const generalizeCommentReport = (
|
||||
saved: false,
|
||||
creator_blocked: false,
|
||||
creator: report.comment_creator,
|
||||
banned_from_community: false,
|
||||
},
|
||||
reason: report.comment_report.reason,
|
||||
type: 'comment',
|
||||
@@ -65,6 +66,7 @@ export const generalizePostReport = (report: PostReportView): ReportView => ({
|
||||
read: false,
|
||||
subscribed: 'NotSubscribed',
|
||||
creator: report.post_creator,
|
||||
banned_from_community: false,
|
||||
},
|
||||
reason: report.post_report.reason,
|
||||
type: 'post',
|
||||
|
||||
Reference in new issue
Block a user