fix: fix profile system

This commit is contained in:
Xyphyn committed 2023-08-22 17:17:51 -07:00
1 parent e02abec9d0
commit 7518c06410
10 files changed
+30 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "0.9.21",
"version": "0.9.22",
"private": true,
"scripts": {
"dev": "vite dev",
+20 -3
View File
@@ -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)
if (id == -1) {
resetProfile()
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 }))
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
}
+1
View File
@@ -54,6 +54,7 @@
const buttonRoundness = {
pill: 'rounded-full',
lg: 'rounded-lg',
md: 'rounded-md',
none: '',
}
+1
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import Button from '$lib/components/input/Button.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
+1 -1
View File
@@ -21,7 +21,7 @@
<div
class="break-words
{getColor(cardColor)} rounded-md {clazz}"
{getColor(cardColor)} rounded-lg {clazz}"
{...$$restProps}
>
<slot />
+1 -1
View File
@@ -105,7 +105,7 @@
<Button
href="/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"
>
{#if $profile?.user?.reports ?? 0 > 0}
@@ -7,6 +7,7 @@
Icon,
Plus,
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import Button from '../../input/Button.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
@@ -85,6 +86,10 @@
</span>
</Button>
{/each}
<SidebarButton href="/accounts" expanded={$userSettings.expandSidebar}>
<Icon src={UserGroup} mini size="16" />
Accounts
</SidebarButton>
{/if}
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
{#if $profile?.user}
View File
Whitespace-only changes.
View File
Whitespace-only changes.
-2
View File
@@ -5,8 +5,6 @@ import type { SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
export async function load({ params, url, fetch }) {
if (!get(profile)?.user) return {}
const page = Number(url.searchParams.get('page')) || 1
const type: 'comments' | 'posts' | 'all' =
(url.searchParams.get('type') as 'comments' | 'posts' | 'all') || 'all'