feat: use state based auth instead of store based (#488)
* misc: switch to state for auth * fix: class based auth not working
This commit is contained in:
1 parent
8c6ff77fac
commit
5651ad475d
83 files changed
+395
-469
No files matched your search
@@ -66,7 +66,7 @@
|
||||
let editingLoad = $state(false)
|
||||
|
||||
async function save() {
|
||||
if (!$profile?.jwt || newComment.length <= 0) return
|
||||
if (!profile.data?.jwt || newComment.length <= 0) return
|
||||
|
||||
editingLoad = true
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
||||
<span class="text-xs">{$t('comment.reply')}</span>
|
||||
</Button>
|
||||
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
|
||||
{#if profile.data?.user && (amMod(profile.data?.user, comment.community) || isAdmin(profile.data.user))}
|
||||
<CommentModerationMenu bind:item={comment} />
|
||||
{/if}
|
||||
<Menu placement="bottom">
|
||||
@@ -92,8 +92,8 @@
|
||||
<Icon src={Square2Stack} mini size="16" />
|
||||
<div>{$t('comment.actions.link')}</div>
|
||||
</MenuButton>
|
||||
{#if $profile?.jwt}
|
||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||
{#if profile.data?.jwt}
|
||||
{#if comment.creator.id == profile.data.user?.local_user_view.person.id}
|
||||
<MenuButton onclick={() => onedit?.(comment)}>
|
||||
<Icon src={PencilSquare} mini size="16" />
|
||||
<span>{$t('post.actions.more.edit')}</span>
|
||||
@@ -101,8 +101,12 @@
|
||||
{/if}
|
||||
<MenuButton
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
comment.saved = await save(comment, !comment.saved, $profile.jwt)
|
||||
if (profile.data?.jwt)
|
||||
comment.saved = await save(
|
||||
comment,
|
||||
!comment.saved,
|
||||
profile.data.jwt,
|
||||
)
|
||||
}}
|
||||
>
|
||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
||||
@@ -110,15 +114,15 @@
|
||||
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||
</span>
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.jwt && $profile.user.local_user_view.person.id == comment.creator.id}
|
||||
{#if profile.data?.user && profile.data.jwt && profile.data.user.local_user_view.person.id == comment.creator.id}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
if (profile.data?.jwt)
|
||||
comment.comment.deleted = await deleteItem(
|
||||
comment,
|
||||
!comment.comment.deleted,
|
||||
$profile.jwt,
|
||||
profile.data.jwt,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -130,7 +134,7 @@
|
||||
</span>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile.jwt && $profile.user?.local_user_view.person.id != comment.creator.id}
|
||||
{#if profile.data.jwt && profile.data.user?.local_user_view.person.id != comment.creator.id}
|
||||
<MenuButton onclick={() => report(comment)} color="danger-subtle">
|
||||
<Icon src={Flag} mini size="16" />
|
||||
<span>{$t('moderation.report')}</span>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
let language: number | undefined = $state()
|
||||
|
||||
async function submit() {
|
||||
if (!$profile?.user || !$profile?.jwt || value == '') return
|
||||
if (!profile.data?.user || !profile.data?.jwt || value == '') return
|
||||
|
||||
loading = true
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
size="square-md"
|
||||
rounding="pill"
|
||||
color={language != undefined ? 'primary' : 'ghost'}
|
||||
title={$t('form.profile.languages.title')}
|
||||
title={$t('form.profile.data.languages.title')}
|
||||
>
|
||||
<Icon src={Language} size="16" micro />
|
||||
</Button>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { getInstance } from '$lib/lemmy.js'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { t } from '$lib/translations'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
}: Props = $props()
|
||||
|
||||
const castVote = async (newVote: number) => {
|
||||
if (!$profile?.jwt) {
|
||||
if (!profile.data?.jwt) {
|
||||
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user