feat: add profile images
This commit is contained in:
1 parent
74f9a9e8fd
commit
6f80d40c43
4 files changed
+38
-16
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "photon-lemmy",
|
||||
"version": "1.4.7",
|
||||
"version": "1.5.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface Profile {
|
||||
jwt?: string
|
||||
user?: PersonData
|
||||
username?: string
|
||||
avatar?: string
|
||||
favorites?: number[]
|
||||
color?: string
|
||||
}
|
||||
@@ -89,7 +90,13 @@ profile.subscribe(async (p) => {
|
||||
...p,
|
||||
user: user!.user,
|
||||
username: user?.user.local_user_view.person.name,
|
||||
avatar: user?.user.local_user_view.person.avatar,
|
||||
}))
|
||||
|
||||
profile.update((pro) => {
|
||||
console.log(pro)
|
||||
return pro
|
||||
})
|
||||
})
|
||||
|
||||
export async function setUser(jwt: string, inst: string, username: string) {
|
||||
@@ -120,6 +127,7 @@ export async function setUser(jwt: string, inst: string, username: string) {
|
||||
instance: inst,
|
||||
jwt: jwt,
|
||||
username: user.user.local_user_view.person.name,
|
||||
avatar: user.user.local_user_view.person.avatar,
|
||||
}
|
||||
|
||||
profile.set({
|
||||
@@ -212,6 +220,7 @@ export async function setUserID(id: number) {
|
||||
const user = await userFromJwt(prof.jwt, prof.instance)
|
||||
instance.set(prof.instance)
|
||||
prof.user = user?.user
|
||||
prof.avatar = user?.user.local_user_view.person.avatar
|
||||
site.set(user?.site)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,7 @@
|
||||
|
||||
switching = false
|
||||
}}
|
||||
class="w-full hover:bg-slate-200 {expanded ? '' : '!p-1.5'} {$profile?.id ==
|
||||
prof.id
|
||||
? 'font-bold'
|
||||
: ''}"
|
||||
class="w-full hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
|
||||
>
|
||||
<ProfileAvatar
|
||||
profile={prof}
|
||||
@@ -43,7 +40,10 @@
|
||||
selected={$profile?.id == prof.id}
|
||||
slot="prefix"
|
||||
/>
|
||||
<span class:hidden={!expanded} class="flex flex-col gap-0">
|
||||
<span
|
||||
class:hidden={!expanded}
|
||||
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-bold' : ''}"
|
||||
>
|
||||
{prof.username ?? prof.user?.local_user_view.person.name}
|
||||
<span class="text-slate-500 dark:text-zinc-400 font-normal text-xs">
|
||||
{prof.instance}
|
||||
|
||||
@@ -9,14 +9,27 @@
|
||||
</script>
|
||||
|
||||
{#if profile}
|
||||
<Icon
|
||||
src={UserCircle}
|
||||
mini={selected}
|
||||
size={`${size}`}
|
||||
title={profile.username}
|
||||
class="text-blue-500 flex-shrink-0"
|
||||
style={profile.color
|
||||
? `color: ${profile.color}`
|
||||
: `filter: hue-rotate(${index * 50}deg)`}
|
||||
/>
|
||||
<div style="width: {size}px; height: {size}px;">
|
||||
{#if profile.avatar && !profile.color}
|
||||
<img
|
||||
src="{profile.avatar}?thumbnail=32&format=webp"
|
||||
alt={profile.username}
|
||||
width={size}
|
||||
height={size}
|
||||
class="flex-shrink-0 rounded-full ring-slate-800/50 dark:ring-zinc-200/50"
|
||||
class:ring-2={selected}
|
||||
/>
|
||||
{:else}
|
||||
<Icon
|
||||
src={UserCircle}
|
||||
mini={selected}
|
||||
size={`${size}`}
|
||||
title={profile.username}
|
||||
class="text-blue-500 flex-shrink-0"
|
||||
style={profile.color
|
||||
? `color: ${profile.color}`
|
||||
: `filter: hue-rotate(${index * 50}deg)`}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
Reference in new issue
Block a user