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
@@ -51,11 +51,12 @@
|
||||
let blocking = false
|
||||
|
||||
async function blockUser(block: number) {
|
||||
if (!$profile?.user || !$profile?.jwt) throw new Error('Unauthenticated')
|
||||
if (!profile.data?.user || !profile.data?.jwt)
|
||||
throw new Error('Unauthenticated')
|
||||
|
||||
blocking = true
|
||||
try {
|
||||
const blocked = isBlocked($profile.user, block)
|
||||
const blocked = isBlocked(profile.data.user, block)
|
||||
|
||||
await getClient().blockPerson({
|
||||
block: !blocked,
|
||||
@@ -63,10 +64,10 @@
|
||||
})
|
||||
|
||||
if (blocked) {
|
||||
const index = $profile.user.person_blocks
|
||||
const index = profile.data.user.person_blocks
|
||||
.map((p) => p.target.id)
|
||||
.indexOf(block)
|
||||
$profile.user.person_blocks.splice(index, 1)
|
||||
profile.data.user.person_blocks.splice(index, 1)
|
||||
}
|
||||
|
||||
toast({
|
||||
@@ -209,7 +210,7 @@
|
||||
</Expandable>
|
||||
{/if}
|
||||
{#snippet actions()}
|
||||
{#if $profile?.user && $profile.jwt && data.person_view.person.id != $profile.user.local_user_view.person.id}
|
||||
{#if profile.data?.user && profile.data.jwt && data.person_view.person.id != profile.data.user.local_user_view.person.id}
|
||||
<div class="flex items-center gap-2 w-full">
|
||||
<Button
|
||||
size="square-md"
|
||||
@@ -234,7 +235,7 @@
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if isAdmin($profile?.user)}
|
||||
{#if isAdmin(profile.data?.user)}
|
||||
<Menu class="ml-auto" placement="bottom-end">
|
||||
{#snippet target()}
|
||||
<Button size="square-md">
|
||||
@@ -280,7 +281,7 @@
|
||||
{#snippet prefix()}
|
||||
<Icon mini size="16" src={NoSymbol} />
|
||||
{/snippet}
|
||||
{isBlocked($profile.user, data.person_view.person.id)
|
||||
{isBlocked(profile.data.user, data.person_view.person.id)
|
||||
? 'Unblock'
|
||||
: 'Block'}
|
||||
</MenuButton>
|
||||
|
||||
Reference in new issue
Block a user