feat: switch to new account system
This commit is contained in:
1 parent
54ab6fdc82
commit
2da415b670
38 files changed
+222
-362
No files matched your search
@@ -5,9 +5,10 @@
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import type { Community, Person, PersonView } from 'lemmy-js-client'
|
||||
import { authData, getClient, user } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import TextInput from '$lib/components/input/TextInput.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let open = false
|
||||
let item: Person | undefined
|
||||
@@ -27,7 +28,7 @@
|
||||
$: if (item) resetReason()
|
||||
|
||||
async function submit() {
|
||||
if (!item || !$user || !community || !$authData) return
|
||||
if (!item || !$profile?.user || !community || !$profile?.jwt) return
|
||||
|
||||
loading = true
|
||||
|
||||
@@ -59,7 +60,7 @@
|
||||
}
|
||||
|
||||
await getClient().banFromCommunity({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
ban: !banned,
|
||||
community_id: community.id,
|
||||
person_id: item.id,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { authData, getClient, user } from '$lib/lemmy'
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import type {
|
||||
CommentView,
|
||||
Community,
|
||||
@@ -13,6 +13,7 @@
|
||||
import { Icon, ShieldExclamation, Trash } from 'svelte-hero-icons'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import { isComment } from '$lib/lemmy/item.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let item: PostView | CommentView
|
||||
</script>
|
||||
@@ -53,7 +54,7 @@
|
||||
{item.post.removed ? 'Restore' : 'Remove'}
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $user && $user.local_user_view.person.id != item.creator.id}
|
||||
{#if $profile.user && $profile.user?.local_user_view.person.id != item.creator.id}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
User
|
||||
</span>
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { authData, getClient, user } from '$lib/lemmy'
|
||||
import type {
|
||||
CommentView,
|
||||
Community,
|
||||
CommunityView,
|
||||
PostView,
|
||||
} from 'lemmy-js-client'
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import type { CommentView, Community, PostView } from 'lemmy-js-client'
|
||||
import { amMod, ban, remove } from './moderation'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
@@ -21,6 +16,7 @@
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import { isComment, isPost } from '$lib/lemmy/item.js'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let item: PostView | CommentView
|
||||
|
||||
@@ -30,12 +26,12 @@
|
||||
$: acting = locking || pinning
|
||||
|
||||
async function lock(lock: boolean) {
|
||||
if (!$authData || !isPost(item)) return
|
||||
if (!$profile?.jwt || !isPost(item)) return
|
||||
locking = true
|
||||
|
||||
try {
|
||||
await getClient().lockPost({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
locked: lock,
|
||||
post_id: item.post.id,
|
||||
})
|
||||
@@ -59,14 +55,14 @@
|
||||
}
|
||||
|
||||
async function pin(pinned: boolean) {
|
||||
if (!$authData || !isPost(item)) return
|
||||
if (!$profile?.jwt || !isPost(item)) return
|
||||
|
||||
pinning = true
|
||||
|
||||
try {
|
||||
await getClient().featurePost({
|
||||
feature_type: 'Community',
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
featured: pinned,
|
||||
post_id: item.post.id,
|
||||
})
|
||||
@@ -149,7 +145,7 @@
|
||||
{item.post.removed ? 'Restore' : 'Remove'}
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $user && $user.local_user_view.person.id != item.creator.id}
|
||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
User
|
||||
</span>
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { isComment, isPost } from '$lib/lemmy/item.js'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let open: boolean
|
||||
export let item: PostView | CommentView | undefined = undefined
|
||||
@@ -23,14 +24,14 @@
|
||||
|
||||
async function remove() {
|
||||
if (!item) return
|
||||
if (!$authData) throw new Error('Unauthenticated')
|
||||
if (!$profile?.jwt) throw new Error('Unauthenticated')
|
||||
|
||||
loading = true
|
||||
|
||||
try {
|
||||
if (isComment(item)) {
|
||||
await getClient().removeComment({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: item.comment.id,
|
||||
removed: !removed,
|
||||
reason: reason || undefined,
|
||||
@@ -38,7 +39,7 @@
|
||||
item.comment.removed = !removed
|
||||
} else if (isPost(item)) {
|
||||
await getClient().removePost({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
post_id: item.post.id,
|
||||
removed: !removed,
|
||||
reason: reason || undefined,
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let open: boolean
|
||||
export let item: PostView | CommentView | undefined = undefined
|
||||
@@ -21,19 +22,19 @@
|
||||
let reason = ''
|
||||
|
||||
async function report() {
|
||||
if (!item || !$authData || reason == '') return
|
||||
if (!item || !$profile?.jwt || reason == '') return
|
||||
loading = true
|
||||
|
||||
try {
|
||||
if (isComment(item)) {
|
||||
await getClient().createCommentReport({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: item.comment.id,
|
||||
reason: reason,
|
||||
})
|
||||
} else if (isPost(item)) {
|
||||
await getClient().createPostReport({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
post_id: item.post.id,
|
||||
reason: reason,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user