fix: fix profile system
This commit is contained in:
1 parent
e02abec9d0
commit
7518c06410
10 files changed
+30
-8
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "0.9.21",
|
"version": "0.9.22",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
+20
-3
@@ -189,17 +189,34 @@ export function deleteProfile(id: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setUserID(id: number) {
|
const serializeUser = (user: Profile): Profile => ({
|
||||||
|
...user,
|
||||||
|
user: undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
export async function setUserID(id: number) {
|
||||||
const pd = get(profileData)
|
const pd = get(profileData)
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
resetProfile()
|
resetProfile()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const prof = pd.profiles.find((p) => p.id == id)
|
|
||||||
|
|
||||||
profile.set(prof ?? getDefaultProfile())
|
let prof = pd.profiles.find((p) => p.id == id)
|
||||||
|
|
||||||
|
if (!prof) return profile.update(() => getDefaultProfile())
|
||||||
|
prof = serializeUser(prof)
|
||||||
|
|
||||||
profileData.update((p) => ({ ...p, profile: id }))
|
profileData.update((p) => ({ ...p, profile: id }))
|
||||||
|
|
||||||
|
if (prof?.jwt) {
|
||||||
|
const user = await userFromJwt(prof.jwt, prof.instance)
|
||||||
|
instance.set(prof.instance)
|
||||||
|
prof.user = user?.user
|
||||||
|
site.set(user?.site)
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.update(() => prof ?? getDefaultProfile())
|
||||||
|
|
||||||
return prof
|
return prof
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
const buttonRoundness = {
|
const buttonRoundness = {
|
||||||
pill: 'rounded-full',
|
pill: 'rounded-full',
|
||||||
|
lg: 'rounded-lg',
|
||||||
md: 'rounded-md',
|
md: 'rounded-md',
|
||||||
none: '',
|
none: '',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="break-words
|
class="break-words
|
||||||
{getColor(cardColor)} rounded-md {clazz}"
|
{getColor(cardColor)} rounded-lg {clazz}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
<Button
|
<Button
|
||||||
href="/moderation"
|
href="/moderation"
|
||||||
aria-label="Moderation"
|
aria-label="Moderation"
|
||||||
class="max-md:w-9 h-8 max-md:!p-0 dark:text-zinc-300 text-slate-700
|
class="max-md:w-9 max-md:h-8 max-md:!p-0 dark:text-zinc-300 text-slate-700
|
||||||
hover:text-inherit hover:bg-slate-200 hover:dark:text-inherit relative hover:border-slate-300"
|
hover:text-inherit hover:bg-slate-200 hover:dark:text-inherit relative hover:border-slate-300"
|
||||||
>
|
>
|
||||||
{#if $profile?.user?.reports ?? 0 > 0}
|
{#if $profile?.user?.reports ?? 0 > 0}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
Icon,
|
Icon,
|
||||||
Plus,
|
Plus,
|
||||||
UserCircle,
|
UserCircle,
|
||||||
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Button from '../../input/Button.svelte'
|
import Button from '../../input/Button.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
@@ -85,6 +86,10 @@
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
<SidebarButton href="/accounts" expanded={$userSettings.expandSidebar}>
|
||||||
|
<Icon src={UserGroup} mini size="16" />
|
||||||
|
Accounts
|
||||||
|
</SidebarButton>
|
||||||
{/if}
|
{/if}
|
||||||
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
||||||
{#if $profile?.user}
|
{#if $profile?.user}
|
||||||
|
|||||||
Whitespace-only changes.
Whitespace-only changes.
@@ -5,8 +5,6 @@ import type { SortType } from 'lemmy-js-client'
|
|||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export async function load({ params, url, fetch }) {
|
export async function load({ params, url, fetch }) {
|
||||||
if (!get(profile)?.user) return {}
|
|
||||||
|
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
const type: 'comments' | 'posts' | 'all' =
|
const type: 'comments' | 'posts' | 'all' =
|
||||||
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'
|
||||||
|
|||||||
Reference in new issue
Block a user