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
@@ -11,16 +11,13 @@
|
||||
import type { CommentNodeI } from './comments'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import CommentForm from './CommentForm.svelte'
|
||||
import { page } from '$app/stores'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
|
||||
import { createEventDispatcher, getContext } from 'svelte'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import TextArea from '$lib/components/input/TextArea.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let node: CommentNodeI
|
||||
export let postId: number
|
||||
@@ -39,11 +36,11 @@
|
||||
bind:open={editing}
|
||||
action="Save"
|
||||
on:action={async () => {
|
||||
if (!$authData || newComment.length <= 0) return
|
||||
if (!$profile?.jwt || newComment.length <= 0) return
|
||||
|
||||
try {
|
||||
await getClient().editComment({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: node.comment_view.comment.id,
|
||||
content: newComment,
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
PencilSquare,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
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 Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
@@ -25,12 +25,13 @@
|
||||
import { amMod, report } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let comment: CommentView
|
||||
export let replying: boolean = false
|
||||
|
||||
async function save() {
|
||||
if (!$authData) return
|
||||
if (!$profile?.jwt) return
|
||||
|
||||
const saved = comment.saved
|
||||
|
||||
@@ -38,7 +39,7 @@
|
||||
|
||||
try {
|
||||
await getClient().saveComment({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: comment.comment.id,
|
||||
save: !saved,
|
||||
})
|
||||
@@ -70,7 +71,7 @@
|
||||
<Icon src={ArrowUturnLeft} width={14} height={14} mini />
|
||||
<span class="text-xs">Reply</span>
|
||||
</Button>
|
||||
{#if $user && amMod($user, comment.community)}
|
||||
{#if $profile?.user && amMod($profile?.user, comment.community)}
|
||||
<CommentModerationMenu item={comment} />
|
||||
{/if}
|
||||
<Menu
|
||||
@@ -89,8 +90,8 @@
|
||||
<Icon src={EllipsisHorizontal} width={16} height={16} mini slot="icon" />
|
||||
</Button>
|
||||
<span class="text-xs opacity-80 py-1 my-1 px-4">Comment actions</span>
|
||||
{#if $authData?.token}
|
||||
{#if comment.creator.id == $user?.local_user_view.person.id}
|
||||
{#if $profile?.jwt}
|
||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||
<MenuButton on:click={() => dispatcher('edit', comment)}>
|
||||
<Icon src={PencilSquare} mini size="16" />
|
||||
<span>Edit</span>
|
||||
@@ -100,14 +101,14 @@
|
||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
||||
<span>{comment.saved ? 'Unsave' : 'Save'}</span>
|
||||
</MenuButton>
|
||||
{#if $user && $authData && isCommentMutable(comment, $user.local_user_view)}
|
||||
{#if $profile?.user && $profile.jwt && isCommentMutable(comment, $profile.user.local_user_view)}
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
on:click={async () => {
|
||||
if (!$authData) return
|
||||
if (!$profile?.jwt) return
|
||||
try {
|
||||
await getClient().deleteComment({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: comment.comment.id,
|
||||
deleted: true,
|
||||
})
|
||||
@@ -127,7 +128,7 @@
|
||||
<span>Delete</span>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $authData && $user?.local_user_view.person.id != comment.creator.id}
|
||||
{#if $profile.jwt && $profile.user?.local_user_view.person.id != comment.creator.id}
|
||||
<MenuButton on:click={() => report(comment)} color="dangerSecondary">
|
||||
<Icon src={Flag} mini size="16" />
|
||||
<span>Report</span>
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import type { CommentResponse } from 'lemmy-js-client'
|
||||
import { authData, getClient, user } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { ToastType, addToast } from '$lib/components/ui/toasts/toasts.js'
|
||||
import TextArea from '$lib/components/input/TextArea.svelte'
|
||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let postId: number
|
||||
export let parentId: number | undefined = undefined
|
||||
@@ -25,13 +26,13 @@
|
||||
let preview = false
|
||||
|
||||
async function submit() {
|
||||
if (!$user || !$authData || value == '') return
|
||||
if (!$profile?.user || !$profile?.jwt || value == '') return
|
||||
|
||||
loading = true
|
||||
|
||||
try {
|
||||
const response = await getClient().createComment({
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
content: value,
|
||||
post_id: postId,
|
||||
parent_id: parentId,
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { Color } from '$lib/ui/colors'
|
||||
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||
import { authData, getClient } from '$lib/lemmy'
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import { userSettings } from '$lib/settings'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let vote: number = 0
|
||||
export let score: number
|
||||
export let commentId: number
|
||||
|
||||
async function upvote() {
|
||||
if (!$authData) return
|
||||
if (!$profile?.jwt) return
|
||||
|
||||
const upvoted = vote == 1
|
||||
|
||||
@@ -26,14 +27,14 @@
|
||||
await getClient()
|
||||
.likeComment({
|
||||
score: upvoted ? 0 : 1,
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: commentId,
|
||||
})
|
||||
.catch((_) => undefined)
|
||||
}
|
||||
|
||||
async function downvote() {
|
||||
if (!$authData) return
|
||||
if (!$profile?.jwt) return
|
||||
|
||||
const upvoted = vote == -1
|
||||
|
||||
@@ -50,7 +51,7 @@
|
||||
await getClient()
|
||||
.likeComment({
|
||||
score: upvoted ? 0 : -1,
|
||||
auth: $authData.token,
|
||||
auth: $profile.jwt,
|
||||
comment_id: commentId,
|
||||
})
|
||||
.catch((_) => undefined)
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
import { onMount, setContext } from 'svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import { ChevronDown, Icon } from 'svelte-hero-icons'
|
||||
import { authData, getClient } from '$lib/lemmy.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { CommentView, Post } from 'lemmy-js-client'
|
||||
import { fly } from 'svelte/transition'
|
||||
import { toast, ToastType } from '$lib/components/ui/toasts/toasts.js'
|
||||
import Modal from '$lib/components/ui/modal/Modal.svelte'
|
||||
import TextArea from '$lib/components/input/TextArea.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
|
||||
export let nodes: CommentNodeI[]
|
||||
export let isParent: boolean
|
||||
@@ -44,7 +43,7 @@
|
||||
parent.loading = true
|
||||
|
||||
const newComments = await getClient($page.params.instance).getComments({
|
||||
auth: $authData?.token,
|
||||
auth: $profile?.jwt,
|
||||
max_depth: 5,
|
||||
parent_id: parent.comment_view.comment.id,
|
||||
type_: 'All',
|
||||
|
||||
Reference in new issue
Block a user