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
+365
-439
No files matched your search
+64
-107
@@ -27,7 +27,7 @@ import { t } from './translations'
|
|||||||
|
|
||||||
const getDefaultProfile = (): Profile => ({
|
const getDefaultProfile = (): Profile => ({
|
||||||
id: -1,
|
id: -1,
|
||||||
instance: get(profileData)?.defaultInstance ?? get(instance),
|
instance: profileData.defaultInstance ?? get(instance),
|
||||||
})
|
})
|
||||||
|
|
||||||
function getFromStorage<T>(key: string): T | undefined {
|
function getFromStorage<T>(key: string): T | undefined {
|
||||||
@@ -83,7 +83,7 @@ const getCookie = (key: string): string | undefined => {
|
|||||||
?.split('=')?.[1]
|
?.split('=')?.[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
export let profileData = writable<ProfileData>(
|
export let profileData = $state<ProfileData>(
|
||||||
getFromStorage<ProfileData>('profileData') ?? {
|
getFromStorage<ProfileData>('profileData') ?? {
|
||||||
profiles: [
|
profiles: [
|
||||||
{
|
{
|
||||||
@@ -97,52 +97,31 @@ export let profileData = writable<ProfileData>(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
let fetchUser = {
|
class CurrentProfile {
|
||||||
loading: false,
|
#data = $derived(
|
||||||
prevProfile: -1,
|
profileData.profiles.find((i) => i.id == profileData.profile) ??
|
||||||
}
|
getDefaultProfile(),
|
||||||
|
)
|
||||||
|
|
||||||
function profileStore(
|
get data() {
|
||||||
data: Writable<ProfileData>,
|
return this.#data
|
||||||
fn: (
|
}
|
||||||
values: ProfileData,
|
set data(value) {
|
||||||
set: (value: Profile) => void,
|
if (!value) return
|
||||||
update: (fn: Updater<Profile>) => void,
|
const index = profileData.profiles.findIndex((i) => i.id == value?.id)
|
||||||
) => any,
|
profileData.profiles[index] = value
|
||||||
) {
|
|
||||||
const derive: Readable<Profile> = derived(data, fn)
|
|
||||||
const { subscribe } = derive
|
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe,
|
|
||||||
set: (value: Profile) => {
|
|
||||||
data.update((data) => {
|
|
||||||
let index = data.profiles.findIndex((t) => t.id == value.id)
|
|
||||||
data.profiles[index] = value
|
|
||||||
return data
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let profile: Readable<Profile> & { set: (v: Profile) => void } =
|
export let profile = new CurrentProfile()
|
||||||
profileStore(profileData, (pd, set, update) => {
|
|
||||||
const profile =
|
|
||||||
pd.profiles.find((p) => p.id == pd.profile) ?? getDefaultProfile()
|
|
||||||
|
|
||||||
instance.set(profile.instance)
|
async function fetchUserData(profile: CurrentProfile) {
|
||||||
set(profile)
|
instance.set(profile.data.instance)
|
||||||
|
if (profile.data.jwt) {
|
||||||
if (profile?.jwt) {
|
|
||||||
if (profile.id != fetchUser.prevProfile && !fetchUser.loading) {
|
|
||||||
site.set(undefined)
|
site.set(undefined)
|
||||||
|
|
||||||
fetchUser.loading = true
|
|
||||||
|
|
||||||
notifications.set({ applications: 0, inbox: 0, reports: 0 })
|
notifications.set({ applications: 0, inbox: 0, reports: 0 })
|
||||||
|
|
||||||
userFromJwt(profile.jwt, profile.instance)
|
const res = await userFromJwt(profile.data.jwt, profile.data.instance)
|
||||||
.then((res) => {
|
|
||||||
if (!res?.user)
|
if (!res?.user)
|
||||||
toast({
|
toast({
|
||||||
content:
|
content:
|
||||||
@@ -151,34 +130,22 @@ export let profile: Readable<Profile> & { set: (v: Profile) => void } =
|
|||||||
})
|
})
|
||||||
|
|
||||||
site.set(res?.site)
|
site.set(res?.site)
|
||||||
|
profile.data.user = res?.user
|
||||||
profile.user = res?.user
|
if (profile.data.user) {
|
||||||
if (profile.user) {
|
profile.data.avatar = res?.user?.local_user_view.person.avatar
|
||||||
profile.avatar = res?.user?.local_user_view.person.avatar
|
profile.data.username = res?.user?.local_user_view.person.name
|
||||||
profile.username = res?.user?.local_user_view.person.name
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchUser.loading = false
|
|
||||||
fetchUser.prevProfile = profile.id
|
|
||||||
checkInbox()
|
|
||||||
|
|
||||||
update(() => profile)
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
fetchUser.loading = false
|
|
||||||
toast({ content: e, type: 'error' })
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (browser && !fetchUser.loading) {
|
if (browser) {
|
||||||
site.set(undefined)
|
site.set(undefined)
|
||||||
client({ instanceURL: profile.instance })
|
client({ instanceURL: profile.data.instance })
|
||||||
.getSite()
|
.getSite()
|
||||||
.then((res) => site.set(res))
|
.then((res) => site.set(res))
|
||||||
fetchUser.loading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
return profile
|
||||||
|
}
|
||||||
|
|
||||||
export let notifications = writable<Notifications>({
|
export let notifications = writable<Notifications>({
|
||||||
applications: 0,
|
applications: 0,
|
||||||
@@ -186,35 +153,40 @@ export let notifications = writable<Notifications>({
|
|||||||
reports: 0,
|
reports: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
profileData.subscribe(async (pd) => {
|
$effect.root(() => {
|
||||||
const serialized: ProfileData = {
|
$effect(() => {
|
||||||
...pd,
|
const serialized = {
|
||||||
profiles: pd.profiles.map((p) => serializeUser(p)),
|
...profileData,
|
||||||
|
profiles: profileData.profiles.map((p) => serializeUser(p)),
|
||||||
}
|
}
|
||||||
|
|
||||||
setFromStorage('profileData', serialized)
|
setFromStorage('profileData', serialized)
|
||||||
|
|
||||||
if (serialized.profile == -1) {
|
if (serialized.profile == -1) {
|
||||||
instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL)
|
instance?.set(profileData.defaultInstance ?? DEFAULT_INSTANCE_URL)
|
||||||
}
|
}
|
||||||
if (serialized.profiles.length == 0) {
|
if (serialized.profiles.length == 0) {
|
||||||
profileData.update((pd) => ({
|
profileData.profiles = [
|
||||||
...pd,
|
|
||||||
profiles: [
|
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
instance: DEFAULT_INSTANCE_URL,
|
instance: DEFAULT_INSTANCE_URL,
|
||||||
username: t.get('account.guest') || 'Guest',
|
username: t.get('account.guest') || 'Guest',
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
profile: 1,
|
profileData.profile = 1
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$effect(() => {})
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (profile.data.id || profileData) fetchUserData(profile).then((res) => {})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
if (
|
if (
|
||||||
env.PUBLIC_MIGRATE_COOKIE &&
|
env.PUBLIC_MIGRATE_COOKIE &&
|
||||||
get(profileData).profiles.length == 0 &&
|
profileData.profiles.length == 0 &&
|
||||||
env.PUBLIC_INSTANCE_URL
|
env.PUBLIC_INSTANCE_URL
|
||||||
) {
|
) {
|
||||||
const jwt = getCookie('jwt')
|
const jwt = getCookie('jwt')
|
||||||
@@ -260,22 +232,14 @@ export async function setUser(jwt: string, inst: string, username?: string) {
|
|||||||
|
|
||||||
instance.set(inst)
|
instance.set(inst)
|
||||||
|
|
||||||
profileData.update((pd) => {
|
const id = Math.max(...profileData.profiles.map((p) => p.id)) + 1
|
||||||
// too lazy to make a decent system
|
profileData.profile = id
|
||||||
const id = Math.max(...pd.profiles.map((p) => p.id)) + 1
|
profileData.profiles.push({
|
||||||
|
|
||||||
const newProfile: Profile = {
|
|
||||||
id: id,
|
id: id,
|
||||||
instance: inst,
|
instance: inst,
|
||||||
jwt: jwt,
|
jwt: jwt,
|
||||||
username: user?.user?.local_user_view.person.name,
|
username: user?.user?.local_user_view.person.name,
|
||||||
avatar: user?.user?.local_user_view.person.avatar,
|
avatar: user?.user?.local_user_view.person.avatar,
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
profile: id,
|
|
||||||
profiles: [newProfile, ...pd.profiles],
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return user
|
return user
|
||||||
@@ -326,20 +290,15 @@ async function userFromJwt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resetProfile() {
|
export function resetProfile() {
|
||||||
profileData.update((p) => ({ ...p, profile: -1 }))
|
profileData.profile = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteProfile(id: number) {
|
export function deleteProfile(id: number) {
|
||||||
profileData.update((pd) => {
|
profileData.profiles.splice(
|
||||||
const index = pd.profiles.findIndex((p) => p.id == id)
|
profileData.profiles.findIndex((p) => p.id == id),
|
||||||
if (index <= -1) return pd
|
1,
|
||||||
|
)
|
||||||
pd.profiles.splice(index, 1)
|
if (id == profileData.profile) resetProfile()
|
||||||
|
|
||||||
if (id == pd.profile) resetProfile()
|
|
||||||
|
|
||||||
return pd
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function serializeUser(user: Profile): Profile {
|
function serializeUser(user: Profile): Profile {
|
||||||
@@ -350,19 +309,19 @@ function serializeUser(user: Profile): Profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setUserID(id: number) {
|
export async function setUserID(id: number) {
|
||||||
profileData.update((p) => ({ ...p, profile: id }))
|
if (!profileData.profiles.find((p) => p.id == id)) return -1
|
||||||
return get(profile)
|
profileData.profile = id
|
||||||
|
return profile
|
||||||
}
|
}
|
||||||
|
|
||||||
export function moveProfile(id: number, up: boolean) {
|
export function moveProfile(id: number, up: boolean) {
|
||||||
const pd = get(profileData)
|
|
||||||
try {
|
try {
|
||||||
const index = pd.profiles.findIndex((i) => i.id == id)
|
const index = profileData.profiles.findIndex((i) => i.id == id)
|
||||||
|
profileData.profiles = moveItem(
|
||||||
profileData.set({
|
profileData.profiles,
|
||||||
...pd,
|
index,
|
||||||
profiles: moveItem(pd.profiles, index, index + (up ? -1 : 1)),
|
index + (up ? -1 : 1),
|
||||||
})
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// we dont care
|
// we dont care
|
||||||
}
|
}
|
||||||
@@ -406,9 +365,7 @@ async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkInbox() {
|
async function checkInbox() {
|
||||||
if (!get(profile)) return
|
const { user, jwt } = profile.data
|
||||||
|
|
||||||
const { user, jwt } = get(profile)!
|
|
||||||
if (!jwt || !user) return
|
if (!jwt || !user) return
|
||||||
|
|
||||||
const notifs = await getNotificationCount(
|
const notifs = await getNotificationCount(
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
let editingLoad = $state(false)
|
let editingLoad = $state(false)
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!$profile?.jwt || newComment.length <= 0) return
|
if (!profile.data?.jwt || newComment.length <= 0) return
|
||||||
|
|
||||||
editingLoad = true
|
editingLoad = true
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
||||||
<span class="text-xs">{$t('comment.reply')}</span>
|
<span class="text-xs">{$t('comment.reply')}</span>
|
||||||
</Button>
|
</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} />
|
<CommentModerationMenu bind:item={comment} />
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
@@ -92,8 +92,8 @@
|
|||||||
<Icon src={Square2Stack} mini size="16" />
|
<Icon src={Square2Stack} mini size="16" />
|
||||||
<div>{$t('comment.actions.link')}</div>
|
<div>{$t('comment.actions.link')}</div>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
{#if comment.creator.id == profile.data.user?.local_user_view.person.id}
|
||||||
<MenuButton onclick={() => onedit?.(comment)}>
|
<MenuButton onclick={() => onedit?.(comment)}>
|
||||||
<Icon src={PencilSquare} mini size="16" />
|
<Icon src={PencilSquare} mini size="16" />
|
||||||
<span>{$t('post.actions.more.edit')}</span>
|
<span>{$t('post.actions.more.edit')}</span>
|
||||||
@@ -101,8 +101,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if ($profile?.jwt)
|
if (profile.data?.jwt)
|
||||||
comment.saved = await save(comment, !comment.saved, $profile.jwt)
|
comment.saved = await save(
|
||||||
|
comment,
|
||||||
|
!comment.saved,
|
||||||
|
profile.data.jwt,
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
<Icon src={comment.saved ? BookmarkSlash : Bookmark} mini size="16" />
|
||||||
@@ -110,15 +114,15 @@
|
|||||||
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
{comment.saved ? $t('post.actions.unsave') : $t('post.actions.save')}
|
||||||
</span>
|
</span>
|
||||||
</MenuButton>
|
</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
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if ($profile?.jwt)
|
if (profile.data?.jwt)
|
||||||
comment.comment.deleted = await deleteItem(
|
comment.comment.deleted = await deleteItem(
|
||||||
comment,
|
comment,
|
||||||
!comment.comment.deleted,
|
!comment.comment.deleted,
|
||||||
$profile.jwt,
|
profile.data.jwt,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -130,7 +134,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/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">
|
<MenuButton onclick={() => report(comment)} color="danger-subtle">
|
||||||
<Icon src={Flag} mini size="16" />
|
<Icon src={Flag} mini size="16" />
|
||||||
<span>{$t('moderation.report')}</span>
|
<span>{$t('moderation.report')}</span>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
let language: number | undefined = $state()
|
let language: number | undefined = $state()
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!$profile?.user || !$profile?.jwt || value == '') return
|
if (!profile.data?.user || !profile.data?.jwt || value == '') return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
size="square-md"
|
size="square-md"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
color={language != undefined ? 'primary' : 'ghost'}
|
color={language != undefined ? 'primary' : 'ghost'}
|
||||||
title={$t('form.profile.languages.title')}
|
title={$t('form.profile.data.languages.title')}
|
||||||
>
|
>
|
||||||
<Icon src={Language} size="16" micro />
|
<Icon src={Language} size="16" micro />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { getInstance } from '$lib/lemmy.js'
|
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import type { CommentView } from 'lemmy-js-client'
|
import type { CommentView } from 'lemmy-js-client'
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
const castVote = async (newVote: number) => {
|
const castVote = async (newVote: number) => {
|
||||||
if (!$profile?.jwt) {
|
if (!profile.data?.jwt) {
|
||||||
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function subscribe() {
|
async function subscribe() {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
loading.subscribing = true
|
loading.subscribing = true
|
||||||
const subscribed =
|
const subscribed =
|
||||||
community_view.subscribed == 'Subscribed' ||
|
community_view.subscribed == 'Subscribed' ||
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex flex-row items-center gap-1 sticky bottom-0 drop-shadow-xl w-full"
|
class="flex flex-row items-center gap-1 sticky bottom-0 drop-shadow-xl w-full"
|
||||||
>
|
>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<Button
|
<Button
|
||||||
disabled={loading.subscribing}
|
disabled={loading.subscribing}
|
||||||
loading={loading.subscribing}
|
loading={loading.subscribing}
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
: $t('cards.community.subscribe')}
|
: $t('cards.community.subscribe')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && amMod($profile.user, community_view.community)}
|
{#if profile.data?.user && amMod(profile.data.user, community_view.community)}
|
||||||
<Button
|
<Button
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community_view.community.name,
|
community_view.community.name,
|
||||||
@@ -275,7 +275,7 @@
|
|||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -289,7 +289,7 @@
|
|||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.user}
|
{#if profile.data?.user}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if profile.data?.user && isAdmin(profile.data.user)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
let formData = $state(passedFormData)
|
let formData = $state(passedFormData)
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
if ((!edit && formData.name == '') || formData.displayName == '') return
|
if ((!edit && formData.name == '') || formData.displayName == '') return
|
||||||
|
|
||||||
formData.submitting = true
|
formData.submitting = true
|
||||||
@@ -94,23 +94,23 @@
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
|
|
||||||
if ($profile.user) {
|
if (profile.data.user) {
|
||||||
const c = $profile.user.moderates
|
const c = profile.data.user.moderates
|
||||||
.map((m) => m.community.id)
|
.map((m) => m.community.id)
|
||||||
.indexOf(res.community_view.community.id)
|
.indexOf(res.community_view.community.id)
|
||||||
if (c != -1) {
|
if (c != -1) {
|
||||||
$profile.user.moderates[c] = {
|
profile.data.user.moderates[c] = {
|
||||||
community: res.community_view.community,
|
community: res.community_view.community,
|
||||||
moderator: $profile.user.local_user_view.person,
|
moderator: profile.data.user.local_user_view.person,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$profile.user = {
|
profile.data.user = {
|
||||||
...$profile.user,
|
...profile.data.user,
|
||||||
moderates: [
|
moderates: [
|
||||||
...$profile.user.moderates,
|
...profile.data.user.moderates,
|
||||||
{
|
{
|
||||||
community: res.community_view.community,
|
community: res.community_view.community,
|
||||||
moderator: $profile.user.local_user_view.person,
|
moderator: profile.data.user.local_user_view.person,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@
|
|||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label={$t('form.profile.displayName')}
|
label={$t('form.profile.data.displayName')}
|
||||||
bind:value={formData.displayName}
|
bind:value={formData.displayName}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-row gap-4 flex-wrap *:flex-1">
|
<div class="flex flex-row gap-4 flex-wrap *:flex-1">
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
|
<SectionTitle>{$t('form.profile.data.languages.title')}</SectionTitle>
|
||||||
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
||||||
{#if $site}
|
{#if $site}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex items-center gap-2 h-max w-max">
|
<div class="flex items-center gap-2 h-max w-max">
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<Subscribe
|
<Subscribe
|
||||||
community={{
|
community={{
|
||||||
community: community,
|
community: community,
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
</Subscribe>
|
</Subscribe>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $profile?.user && $profile.user.moderates
|
{#if profile.data?.user && profile.data.user.moderates
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(community.id)}
|
.includes(community.id)}
|
||||||
<Button
|
<Button
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<Icon src={Newspaper} size="16" mini />
|
<Icon src={Newspaper} size="16" mini />
|
||||||
{$t('cards.community.modlog')}
|
{$t('cards.community.modlog')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -192,7 +192,7 @@
|
|||||||
? $t('cards.community.unblock')
|
? $t('cards.community.unblock')
|
||||||
: $t('cards.community.block')}
|
: $t('cards.community.block')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.user}
|
{#if profile.data?.user}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
size="lg"
|
size="lg"
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
{$t('cards.community.blockInstance')}
|
{$t('cards.community.blockInstance')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if profile.data?.user && isAdmin(profile.data.user)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
<Subscribe {community}>
|
<Subscribe {community}>
|
||||||
{#snippet children({ subscribe, subscribing })}
|
{#snippet children({ subscribe, subscribing })}
|
||||||
<Button
|
<Button
|
||||||
disabled={subscribing || !$profile?.jwt}
|
disabled={subscribing || !profile.data?.jwt}
|
||||||
loading={subscribing}
|
loading={subscribing}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
const res = await subscribe()
|
const res = await subscribe()
|
||||||
|
|||||||
@@ -52,14 +52,14 @@
|
|||||||
<Option value="Local" icon={MapPin}>{$t('filter.location.local')}</Option>
|
<Option value="Local" icon={MapPin}>{$t('filter.location.local')}</Option>
|
||||||
<Option
|
<Option
|
||||||
value="Subscribed"
|
value="Subscribed"
|
||||||
disabled={$profile?.jwt == undefined}
|
disabled={profile.data?.jwt == undefined}
|
||||||
icon={Newspaper}
|
icon={Newspaper}
|
||||||
>
|
>
|
||||||
{$t('filter.location.subscribed')}
|
{$t('filter.location.subscribed')}
|
||||||
</Option>
|
</Option>
|
||||||
<Option
|
<Option
|
||||||
value="ModeratorView"
|
value="ModeratorView"
|
||||||
disabled={!$profile?.jwt || !amModOfAny($profile?.user)}
|
disabled={!profile.data?.jwt || !amModOfAny(profile.data?.user)}
|
||||||
icon={ShieldCheck}
|
icon={ShieldCheck}
|
||||||
>
|
>
|
||||||
{$t('filter.location.moderator')}
|
{$t('filter.location.moderator')}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
avatar
|
avatar
|
||||||
avatarSize={20}
|
avatarSize={20}
|
||||||
/>
|
/>
|
||||||
{#if $profile?.user?.local_user_view.person.id != message.recipient.id}
|
{#if profile.data?.user?.local_user_view.person.id != message.recipient.id}
|
||||||
to
|
to
|
||||||
<UserLink
|
<UserLink
|
||||||
showInstance={false}
|
showInstance={false}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
{#snippet title()}
|
{#snippet customTitle()}
|
||||||
<h1 class="text-2xl font-bold">
|
<h1 class="text-2xl font-bold">
|
||||||
{$t('routes.admin.applications.modalTitle')}
|
{$t('routes.admin.applications.modalTitle')}
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
async function upload() {
|
async function upload() {
|
||||||
if (!$profile?.jwt || image == null) return
|
if (!profile.data?.jwt || image == null) return
|
||||||
|
|
||||||
progress = 0
|
progress = 0
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
const uploaded = (
|
const uploaded = (
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
Array.from(image).map((i) =>
|
Array.from(image).map((i) =>
|
||||||
uploadImage(i, $profile.instance, $profile.jwt!)
|
uploadImage(i, profile.data.instance, profile.data.jwt!)
|
||||||
.then((uploaded) => {
|
.then((uploaded) => {
|
||||||
progress += 1 / (image?.length ?? 0)
|
progress += 1 / (image?.length ?? 0)
|
||||||
return uploaded
|
return uploaded
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
async function sendMessage() {
|
async function sendMessage() {
|
||||||
if (!$profile?.jwt || message == '') return
|
if (!profile.data?.jwt || message == '') return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
{#snippet title()}
|
{#snippet customTitle()}
|
||||||
<h1 class="text-2xl font-bold">Message</h1>
|
<h1 class="text-2xl font-bold">Message</h1>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<form onsubmit={preventDefault(sendMessage)} class="flex flex-col gap-4">
|
<form onsubmit={preventDefault(sendMessage)} class="flex flex-col gap-4">
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!item || !$profile?.user || !$profile?.jwt) return
|
if (!item || !profile.data?.user || !profile.data?.jwt) return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
<ShieldIcon filled width={14} />
|
<ShieldIcon filled width={14} />
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
{#if (profile.data?.user && amMod(profile.data.user, item.community)) || (profile.data?.user && isAdmin(profile.data.user))}
|
||||||
<MenuDivider>
|
<MenuDivider>
|
||||||
{#if !item.community.local && !amMod($profile.user, item.community)}
|
{#if !item.community.local && !amMod(profile.data.user, item.community)}
|
||||||
{$t('moderation.labelInstanceOnly')}
|
{$t('moderation.labelInstanceOnly')}
|
||||||
{:else}
|
{:else}
|
||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
|
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.user && $profile.user?.local_user_view.person.id != item.creator.id}
|
{#if profile.data?.user && profile.data.user?.local_user_view.person.id != item.creator.id}
|
||||||
<!--Comment made by someone else-->
|
<!--Comment made by someone else-->
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
@@ -72,12 +72,12 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
color="success-subtle"
|
color="success-subtle"
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (!$profile.jwt) return
|
if (!profile.data.jwt) return
|
||||||
item.comment = (
|
item.comment = (
|
||||||
await feature(
|
await feature(
|
||||||
!item.comment.distinguished,
|
!item.comment.distinguished,
|
||||||
item.comment,
|
item.comment,
|
||||||
$profile.jwt,
|
profile.data.jwt,
|
||||||
)
|
)
|
||||||
).comment_view.comment
|
).comment_view.comment
|
||||||
}}
|
}}
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if profile.data?.user && isAdmin(profile.data.user)}
|
||||||
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
|
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
let acting = $derived(locking || pinning)
|
let acting = $derived(locking || pinning)
|
||||||
|
|
||||||
async function lock(lock: boolean) {
|
async function lock(lock: boolean) {
|
||||||
if (!$profile?.jwt || !isPostView(item)) return
|
if (!profile.data?.jwt || !isPostView(item)) return
|
||||||
locking = true
|
locking = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function pin(pinned: boolean, toInstance: boolean = false) {
|
async function pin(pinned: boolean, toInstance: boolean = false) {
|
||||||
if (!$profile?.jwt || !isPostView(item)) return
|
if (!profile.data?.jwt || !isPostView(item)) return
|
||||||
|
|
||||||
pinning = true
|
pinning = true
|
||||||
|
|
||||||
@@ -87,9 +87,9 @@
|
|||||||
<ShieldIcon filled width={16} />
|
<ShieldIcon filled width={16} />
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
{#if (profile.data?.user && amMod(profile.data.user, item.community)) || (profile.data?.user && isAdmin(profile.data.user))}
|
||||||
<MenuDivider>
|
<MenuDivider>
|
||||||
{#if !item.community.local && !amMod($profile.user, item.community)}
|
{#if !item.community.local && !amMod(profile.data.user, item.community)}
|
||||||
{$t('moderation.labelInstanceOnly')}
|
{$t('moderation.labelInstanceOnly')}
|
||||||
{:else}
|
{:else}
|
||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
? $t('moderation.unfeature')
|
? $t('moderation.unfeature')
|
||||||
: $t('moderation.feature')}
|
: $t('moderation.feature')}
|
||||||
</span>
|
</span>
|
||||||
{#if isAdmin($profile.user)}
|
{#if isAdmin(profile.data.user)}
|
||||||
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
|
<span class="text-xs opacity-80">{$t('form.post.community')}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
|
{item.post.removed ? $t('moderation.restore') : $t('moderation.remove')}
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
{#if profile.data?.user && profile.data.user.local_user_view.person.id != item.creator.id}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
onclick={() =>
|
onclick={() =>
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if profile.data?.user && isAdmin(profile.data.user)}
|
||||||
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
color="success-subtle"
|
color="success-subtle"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
async function remove() {
|
async function remove() {
|
||||||
if (!item) return
|
if (!item) return
|
||||||
if (!$profile?.jwt) throw new Error('Unauthenticated')
|
if (!profile.data?.jwt) throw new Error('Unauthenticated')
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@
|
|||||||
bind:value={reason}
|
bind:value={reason}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if !removed && $profile?.user && (amMod($profile.user, item.community) || (isAdmin($profile.user) && item.community.local))}
|
{#if !removed && profile.data?.user && (amMod(profile.data.user, item.community) || (isAdmin(profile.data.user) && item.community.local))}
|
||||||
<Switch bind:checked={commentReason}>
|
<Switch bind:checked={commentReason}>
|
||||||
{$t('moderation.removeSubmission.withReason')}
|
{$t('moderation.removeSubmission.withReason')}
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
let reason = $state('')
|
let reason = $state('')
|
||||||
|
|
||||||
async function report() {
|
async function report() {
|
||||||
if (!item || !$profile?.jwt || reason == '') return
|
if (!item || !profile.data?.jwt || reason == '') return
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,21 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
|
||||||
import { getInstance } from '$lib/lemmy.js'
|
|
||||||
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
|
||||||
import { settings, type View } from '$lib/settings.svelte.js'
|
import { settings, type View } from '$lib/settings.svelte.js'
|
||||||
import PostLink from '$lib/components/lemmy/post/link/PostLink.svelte'
|
|
||||||
import PostMeta, {
|
import PostMeta, {
|
||||||
parseTags,
|
parseTags,
|
||||||
type Tag,
|
type Tag,
|
||||||
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
} from '$lib/components/lemmy/post/PostMeta.svelte'
|
||||||
import { Badge, Material, toast } from 'mono-svelte'
|
import { Badge } from 'mono-svelte'
|
||||||
import {
|
import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js'
|
||||||
bestImageURL,
|
|
||||||
mediaType,
|
|
||||||
postLink,
|
|
||||||
} from '$lib/components/lemmy/post/helpers.js'
|
|
||||||
import Empty from '$lib/components/helper/Empty.svelte'
|
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { ArrowUp, ChatBubbleOvalLeft, Icon } from 'svelte-hero-icons'
|
import { ArrowUp, ChatBubbleOvalLeft, Icon } from 'svelte-hero-icons'
|
||||||
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
||||||
@@ -128,7 +120,7 @@
|
|||||||
admin: post.creator_is_admin,
|
admin: post.creator_is_admin,
|
||||||
moderator: post.creator_is_moderator,
|
moderator: post.creator_is_moderator,
|
||||||
}}
|
}}
|
||||||
subscribed={$profile?.user?.follows
|
subscribed={profile.data?.user?.follows
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community.id)
|
.includes(post.community.id)
|
||||||
? 'Subscribed'
|
? 'Subscribed'
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { PostView } from 'lemmy-js-client'
|
import type { PostView } from 'lemmy-js-client'
|
||||||
import PostVote from './PostVote.svelte'
|
import PostVote from './PostVote.svelte'
|
||||||
import { getInstance, site } from '$lib/lemmy.js'
|
import { site } from '$lib/lemmy.js'
|
||||||
import {
|
import {
|
||||||
ArrowsUpDown,
|
ArrowsUpDown,
|
||||||
ArrowTopRightOnSquare,
|
ArrowTopRightOnSquare,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
BookmarkSlash,
|
BookmarkSlash,
|
||||||
BugAnt,
|
BugAnt,
|
||||||
ChatBubbleLeftEllipsis,
|
|
||||||
ChatBubbleOvalLeft,
|
ChatBubbleOvalLeft,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
CheckBadge,
|
|
||||||
Clock,
|
Clock,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Eye,
|
Eye,
|
||||||
@@ -19,20 +17,16 @@
|
|||||||
Flag,
|
Flag,
|
||||||
GlobeAmericas,
|
GlobeAmericas,
|
||||||
Icon,
|
Icon,
|
||||||
Language,
|
|
||||||
MapPin,
|
MapPin,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
Pencil,
|
Pencil,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
ServerStack,
|
|
||||||
Share,
|
Share,
|
||||||
Star,
|
|
||||||
Trash,
|
Trash,
|
||||||
UserCircle,
|
UserCircle,
|
||||||
XMark,
|
XMark,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import { createEventDispatcher } from 'svelte'
|
|
||||||
import {
|
import {
|
||||||
amMod,
|
amMod,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
@@ -101,7 +95,7 @@
|
|||||||
<div class="mx-auto h-96 flex justify-center items-center">
|
<div class="mx-auto h-96 flex justify-center items-center">
|
||||||
<Spinner width={32} />
|
<Spinner width={32} />
|
||||||
</div>
|
</div>
|
||||||
{:then {default: PostForm }}
|
{:then { default: PostForm }}
|
||||||
<PostForm
|
<PostForm
|
||||||
edit
|
edit
|
||||||
editingPost={post.post}
|
editingPost={post.post}
|
||||||
@@ -131,7 +125,7 @@
|
|||||||
score={post.counts.score}
|
score={post.counts.score}
|
||||||
upvotes={post.counts.upvotes}
|
upvotes={post.counts.upvotes}
|
||||||
downvotes={post.counts.downvotes}
|
downvotes={post.counts.downvotes}
|
||||||
showCounts={$profile?.user?.local_user_view?.local_user?.show_scores ??
|
showCounts={profile.data?.user?.local_user_view?.local_user?.show_scores ??
|
||||||
true}
|
true}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -176,7 +170,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
{#if profile.data?.user && (amMod(profile.data.user, post.community) || isAdmin(profile.data.user))}
|
||||||
<ModerationMenu
|
<ModerationMenu
|
||||||
size="custom"
|
size="custom"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
@@ -187,12 +181,12 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<Button
|
<Button
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
saving = true
|
saving = true
|
||||||
post.saved = await save(post, !post.saved, $profile?.jwt)
|
post.saved = await save(post, !post.saved, profile.data?.jwt)
|
||||||
saving = false
|
saving = false
|
||||||
}}
|
}}
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -304,7 +298,7 @@
|
|||||||
<MenuDivider>
|
<MenuDivider>
|
||||||
{$t('post.actions.more.actions')}
|
{$t('post.actions.more.actions')}
|
||||||
</MenuDivider>
|
</MenuDivider>
|
||||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
{#if profile.data?.user && profile.data?.jwt && profile.data.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton onclick={() => (editing = true)}>
|
<MenuButton onclick={() => (editing = true)}>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={PencilSquare} size="16" micro />
|
<Icon src={PencilSquare} size="16" micro />
|
||||||
@@ -312,11 +306,15 @@
|
|||||||
{$t('post.actions.more.edit')}
|
{$t('post.actions.more.edit')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if ($profile?.jwt)
|
if (profile.data?.jwt)
|
||||||
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
post.read = await markAsRead(
|
||||||
|
post.post,
|
||||||
|
!post.read,
|
||||||
|
profile.data.jwt,
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -331,12 +329,12 @@
|
|||||||
onclick={() => {
|
onclick={() => {
|
||||||
navigator.share?.({
|
navigator.share?.({
|
||||||
url: localShare
|
url: localShare
|
||||||
? `${instanceToURL(getInstance())}/post/${post.post.id}`
|
? `${instanceToURL(profile.data.instance)}/post/${post.post.id}`
|
||||||
: post.post.ap_id,
|
: post.post.ap_id,
|
||||||
}) ??
|
}) ??
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
localShare
|
localShare
|
||||||
? `${instanceToURL(getInstance())}/post/${post.post.id}`
|
? `${instanceToURL(profile.data.instance)}/post/${post.post.id}`
|
||||||
: post.post.ap_id,
|
: post.post.ap_id,
|
||||||
)
|
)
|
||||||
toast({ content: $t('toast.copied') })
|
toast({ content: $t('toast.copied') })
|
||||||
@@ -371,7 +369,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
setSessionStorage('postDraft', {
|
setSessionStorage('postDraft', {
|
||||||
@@ -400,14 +398,14 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('post.actions.more.crosspost')}
|
{$t('post.actions.more.crosspost')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
{#if profile.data.user && post.creator.id == profile.data.user.local_user_view.person.id}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if ($profile?.jwt)
|
if (profile.data?.jwt)
|
||||||
post.post.deleted = await deleteItem(
|
post.post.deleted = await deleteItem(
|
||||||
post,
|
post,
|
||||||
!post.post.deleted,
|
!post.post.deleted,
|
||||||
$profile.jwt,
|
profile.data.jwt,
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
color="danger-subtle"
|
color="danger-subtle"
|
||||||
@@ -420,15 +418,15 @@
|
|||||||
: $t('post.actions.more.delete')}
|
: $t('post.actions.more.delete')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile.user?.local_user_view.person.id != post.creator.id}
|
{#if profile.data.user?.local_user_view.person.id != post.creator.id}
|
||||||
{#if feature('hidePosts', $site?.version)}
|
{#if feature('hidePosts', $site?.version)}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
const hidden = await hidePost(
|
const hidden = await hidePost(
|
||||||
post.post.id,
|
post.post.id,
|
||||||
!post.hidden,
|
!post.hidden,
|
||||||
$profile?.jwt,
|
profile.data?.jwt,
|
||||||
)
|
)
|
||||||
post.hidden = hidden
|
post.hidden = hidden
|
||||||
if (hidden) onhide?.(hidden)
|
if (hidden) onhide?.(hidden)
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { stopPropagation } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { Badge, Popover } from 'mono-svelte'
|
import { Badge, Popover } from 'mono-svelte'
|
||||||
@@ -63,7 +61,6 @@
|
|||||||
Trash,
|
Trash,
|
||||||
PaperAirplane,
|
PaperAirplane,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { getInstance } from '$lib/lemmy.js'
|
|
||||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||||
import { settings, type View } from '$lib/settings.svelte'
|
import { settings, type View } from '$lib/settings.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
@@ -71,6 +68,7 @@
|
|||||||
import { Pencil, type IconSource } from 'svelte-hero-icons'
|
import { Pencil, type IconSource } from 'svelte-hero-icons'
|
||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community?: Community | undefined
|
community?: Community | undefined
|
||||||
@@ -287,7 +285,7 @@
|
|||||||
</header>
|
</header>
|
||||||
{#if title && id}
|
{#if title && id}
|
||||||
<a
|
<a
|
||||||
href="/post/{getInstance()}/{id}"
|
href="/post/{profile.data.instance}/{id}"
|
||||||
class="inline hover:underline
|
class="inline hover:underline
|
||||||
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
|
hover:text-primary-900 hover:dark:text-primary-100 transition-colors max-[480px]:!mt-0
|
||||||
{settings.font == 'satoshi/nunito'
|
{settings.font == 'satoshi/nunito'
|
||||||
|
|||||||
@@ -54,14 +54,14 @@
|
|||||||
let oldScore = score
|
let oldScore = score
|
||||||
|
|
||||||
const castVote = async (newVote: number) => {
|
const castVote = async (newVote: number) => {
|
||||||
if (!$profile?.jwt) {
|
if (!profile.data?.jwt) {
|
||||||
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
toast({ content: $t('toast.loginVoteGate'), type: 'warning' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loading = true
|
loading = true
|
||||||
oldScore = score
|
oldScore = score
|
||||||
vote = newVote
|
vote = newVote
|
||||||
const res = await voteItem(post, newVote, $profile.jwt).catch((e) => {
|
const res = await voteItem(post, newVote, profile.data.jwt).catch((e) => {
|
||||||
toast({ content: errorMessage(e), type: 'error' })
|
toast({ content: errorMessage(e), type: 'error' })
|
||||||
return { upvotes: 0, downvotes: 0, score: 0 }
|
return { upvotes: 0, downvotes: 0, score: 0 }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!data.title || !$profile?.jwt) return
|
if (!data.title || !profile.data?.jwt) return
|
||||||
if (data.url && data.url != '') {
|
if (data.url && data.url != '') {
|
||||||
try {
|
try {
|
||||||
new URL(data.url)
|
new URL(data.url)
|
||||||
@@ -278,7 +278,7 @@
|
|||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
bind:q={communitySearch}
|
bind:q={communitySearch}
|
||||||
items={communities}
|
items={communities}
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
label={$t('form.post.community')}
|
label={$t('form.post.community')}
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { client, getInstance } from '$lib/lemmy.js'
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { client } from '$lib/lemmy.js'
|
||||||
import type { View } from '$lib/settings.svelte'
|
import type { View } from '$lib/settings.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image'
|
import { isImage, isVideo } from '$lib/ui/image'
|
||||||
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
|
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
|
||||||
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
import type { CommentView, PersonView, Post, PostView } from 'lemmy-js-client'
|
||||||
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
export const isCommentMutable = (comment: CommentView, me: PersonView) =>
|
||||||
me.person.id == comment.creator.id
|
me.person.id == comment.creator.id
|
||||||
@@ -57,7 +59,8 @@ export const isYoutubeLink = (url?: string): RegExpMatchArray | null => {
|
|||||||
return url?.match?.(YOUTUBE_REGEX)
|
return url?.match?.(YOUTUBE_REGEX)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const postLink = (post: Post) => `/post/${getInstance()}/${post.id}`
|
export const postLink = (post: Post) =>
|
||||||
|
`/post/${profile.data.instance}/${post.id}`
|
||||||
|
|
||||||
export type MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none'
|
export type MediaType = 'video' | 'image' | 'iframe' | 'embed' | 'none'
|
||||||
export type IframeType = 'youtube' | 'video' | 'none'
|
export type IframeType = 'youtube' | 'video' | 'none'
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
let customHref = (href?: string) => {
|
let customHref = (href?: string) => {
|
||||||
if (href?.startsWith('?')) {
|
if (href?.startsWith('?')) {
|
||||||
const current = pageData.url.searchParams
|
const current = new URLSearchParams(pageData.url.searchParams)
|
||||||
const newParams = new URLSearchParams(href)
|
const newParams = new URLSearchParams(href)
|
||||||
|
|
||||||
current.delete(newParams.keys().toArray()[0])
|
current.delete(newParams.keys().toArray()[0])
|
||||||
@@ -56,11 +56,7 @@
|
|||||||
<Button
|
<Button
|
||||||
href={customHref(href?.(cursor?.back ?? page - 1))}
|
href={customHref(href?.(cursor?.back ?? page - 1))}
|
||||||
color="ghost"
|
color="ghost"
|
||||||
onclick={() => {
|
onclick={() => invalidateAll()}
|
||||||
invalidateAll()
|
|
||||||
if (cursor?.back) onchangecursor?.(cursor.back)
|
|
||||||
else onchange?.(--page)
|
|
||||||
}}
|
|
||||||
title={$t('common.back')}
|
title={$t('common.back')}
|
||||||
size="square-md"
|
size="square-md"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
@@ -91,11 +87,7 @@
|
|||||||
<Button
|
<Button
|
||||||
href={customHref(href?.(cursor?.next ?? page + 1))}
|
href={customHref(href?.(cursor?.next ?? page + 1))}
|
||||||
color="ghost"
|
color="ghost"
|
||||||
onclick={() => {
|
onclick={() => invalidateAll()}
|
||||||
invalidateAll()
|
|
||||||
if (cursor?.next) onchangecursor?.(cursor?.next)
|
|
||||||
else onchange?.(++page)
|
|
||||||
}}
|
|
||||||
title={$t('common.next')}
|
title={$t('common.next')}
|
||||||
size="square-md"
|
size="square-md"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
style="border-radius: inherit;"
|
style="border-radius: inherit;"
|
||||||
>
|
>
|
||||||
<div class="ml-auto"></div>
|
<div class="ml-auto"></div>
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#if profile.data?.user && isAdmin(profile.data.user)}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/admin"
|
href="/admin"
|
||||||
label={$t('nav.admin')}
|
label={$t('nav.admin')}
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</NavButton>
|
</NavButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if amModOfAny($profile?.user)}
|
{#if amModOfAny(profile.data?.user)}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/moderation"
|
href="/moderation"
|
||||||
label={$t('nav.moderation')}
|
label={$t('nav.moderation')}
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
/>
|
/>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<MenuDivider>{$t('nav.create.label')}</MenuDivider>
|
<MenuDivider>{$t('nav.create.label')}</MenuDivider>
|
||||||
<MenuButton link href="/create/post" disabled={!$profile?.jwt}>
|
<MenuButton link href="/create/post" disabled={!profile.data?.jwt}>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={PencilSquare} size="16" micro />
|
<Icon src={PencilSquare} size="16" micro />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
@@ -133,17 +133,17 @@
|
|||||||
<MenuButton
|
<MenuButton
|
||||||
link
|
link
|
||||||
href="/create/community"
|
href="/create/community"
|
||||||
disabled={!$profile?.jwt ||
|
disabled={!profile.data?.jwt ||
|
||||||
!$profile?.user ||
|
!profile.data?.user ||
|
||||||
($site?.site_view.local_site.community_creation_admin_only &&
|
($site?.site_view.local_site.community_creation_admin_only &&
|
||||||
!isAdmin($profile.user))}
|
!isAdmin(profile.data.user))}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Newspaper} size="16" micro />
|
<Icon src={Newspaper} size="16" micro />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('nav.create.community')}
|
{$t('nav.create.community')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{#if !$profile?.jwt}
|
{#if !profile.data?.jwt}
|
||||||
<span class="text-sm mx-4 my-1 py-1">
|
<span class="text-sm mx-4 my-1 py-1">
|
||||||
{$t('nav.create.logingate')}
|
{$t('nav.create.logingate')}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -74,14 +74,14 @@
|
|||||||
hover:border-primary-900 hover:dark:border-primary-100 active:scale-95 {buttonClass}"
|
hover:border-primary-900 hover:dark:border-primary-100 active:scale-95 {buttonClass}"
|
||||||
title={$t('profile.profile')}
|
title={$t('profile.profile')}
|
||||||
>
|
>
|
||||||
{#if $profile?.user}
|
{#if profile.data?.user}
|
||||||
<div
|
<div
|
||||||
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center"
|
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center"
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
url={$profile.user.local_user_view.person.avatar}
|
url={profile.data.user.local_user_view.person.avatar}
|
||||||
width={36}
|
width={36}
|
||||||
alt={$profile.user.local_user_view.person.name}
|
alt={profile.data.user.local_user_view.person.name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if $notifications.inbox > 0}
|
{#if $notifications.inbox > 0}
|
||||||
@@ -96,9 +96,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</button>
|
</button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if $profile?.user}
|
{#if profile.data?.user}
|
||||||
<UserLink
|
<UserLink
|
||||||
user={$profile?.user.local_user_view.person}
|
user={profile.data?.user.local_user_view.person}
|
||||||
showInstance={false}
|
showInstance={false}
|
||||||
avatar
|
avatar
|
||||||
avatarSize={24}
|
avatarSize={24}
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
|
<MenuDivider>{$t('nav.menu.label')}</MenuDivider>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<MenuButton link href="/profile">
|
<MenuButton link href="/profile">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={UserCircle} micro width={16} />
|
<Icon src={UserCircle} micro width={16} />
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
href={action.href}
|
href={action.href}
|
||||||
onclick
|
|
||||||
alignment="left"
|
alignment="left"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="lg"
|
size="lg"
|
||||||
|
|||||||
@@ -229,8 +229,8 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
groups = getGroups(
|
groups = getGroups(
|
||||||
$resumables,
|
$resumables,
|
||||||
$profile,
|
profile.data,
|
||||||
$profileData.profiles,
|
profileData.profiles,
|
||||||
$themeData,
|
$themeData,
|
||||||
page.data.contextual?.actions,
|
page.data.contextual?.actions,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export function getGroups(
|
|||||||
name: t.get('nav.communities'),
|
name: t.get('nav.communities'),
|
||||||
icon: GlobeAlt,
|
icon: GlobeAlt,
|
||||||
},
|
},
|
||||||
...(amModOfAny(profile.user)
|
...(amModOfAny(profile.data.user)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
href: '/moderation',
|
href: '/moderation',
|
||||||
@@ -101,7 +101,7 @@ export function getGroups(
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
...(profile.user && isAdmin(profile.user)
|
...(profile.data.user && isAdmin(profile.data.user)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
href: '/admin',
|
href: '/admin',
|
||||||
@@ -236,23 +236,23 @@ export function getGroups(
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t.get('profile.profile'),
|
name: t.get('profile.data.profile'),
|
||||||
actions: profile.jwt
|
actions: profile.data.jwt
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
href: '/profile/user',
|
href: '/profile/user',
|
||||||
name: t.get('profile.profile'),
|
name: t.get('profile.data.profile'),
|
||||||
icon: UserCircle,
|
icon: UserCircle,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/inbox',
|
href: '/inbox',
|
||||||
name: t.get('profile.inbox'),
|
name: t.get('profile.data.inbox'),
|
||||||
icon: Inbox,
|
icon: Inbox,
|
||||||
shortcut: 'i',
|
shortcut: 'i',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: '/saved',
|
href: '/saved',
|
||||||
name: t.get('profile.saved'),
|
name: t.get('profile.data.saved'),
|
||||||
icon: Bookmark,
|
icon: Bookmark,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -311,7 +311,7 @@ export function getGroups(
|
|||||||
icon: p.avatar ?? UserCircle,
|
icon: p.avatar ?? UserCircle,
|
||||||
detail: p.instance,
|
detail: p.instance,
|
||||||
handle: async () => {
|
handle: async () => {
|
||||||
if (profile.id != p.id) {
|
if (profile.data.id != p.id) {
|
||||||
await setUserID(p.id)
|
await setUserID(p.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,9 +407,9 @@ export function getGroups(
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t.get('profile.subscribed'),
|
name: t.get('profile.data.subscribed'),
|
||||||
actions:
|
actions:
|
||||||
profile?.user?.follows.map((f) => ({
|
profile.data?.user?.follows.map((f) => ({
|
||||||
icon: f.community.icon,
|
icon: f.community.icon,
|
||||||
name: f.community.title,
|
name: f.community.title,
|
||||||
href: `/c/${fullCommunityName(
|
href: `/c/${fullCommunityName(
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
animate:flip={{ duration: 500, easing: expoOut }}
|
||||||
>
|
>
|
||||||
<div class="flex-none grid group">
|
<div class="flex-none grid group">
|
||||||
{#if $profile && !hasFavorite($profile, follow.id)}
|
{#if profile && !hasFavorite(profile.data, follow.id)}
|
||||||
<Button
|
<Button
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
>
|
>
|
||||||
<Icon src={Star} size="16" mini />
|
<Icon src={Star} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
{:else if isFavorites && $profile && hasFavorite($profile, follow.id)}
|
{:else if isFavorites && profile && hasFavorite(profile.data, follow.id)}
|
||||||
<Button
|
<Button
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
alt={follow.name}
|
alt={follow.name}
|
||||||
title={follow.title}
|
title={follow.title}
|
||||||
width={28}
|
width={28}
|
||||||
class={!isFavorites && $profile && hasFavorite($profile, follow.id)
|
class={!isFavorites && profile && hasFavorite(profile.data, follow.id)
|
||||||
? ''
|
? ''
|
||||||
: 'group-hover:hidden'}
|
: 'group-hover:hidden'}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -23,21 +23,22 @@
|
|||||||
alignment="left"
|
alignment="left"
|
||||||
loading={switching}
|
loading={switching}
|
||||||
loaderWidth={20}
|
loaderWidth={20}
|
||||||
selected={$profile?.id == prof.id}
|
selected={profile.data?.id == prof.id}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
switching = true
|
switching = true
|
||||||
|
|
||||||
if ($profile?.id != prof.id) {
|
if (profile.data?.id != prof.id) {
|
||||||
await setUserID(prof.id)
|
await setUserID(prof.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
await goto(page.url, {
|
console.log(page.url)
|
||||||
invalidateAll: true,
|
// await goto(page.url, {
|
||||||
})
|
// invalidateAll: true,
|
||||||
|
// })
|
||||||
|
|
||||||
switching = false
|
switching = false
|
||||||
}}
|
}}
|
||||||
class="w-full font-normal {$profile?.id == prof.id
|
class="w-full font-normal {profile.data?.id == prof.id
|
||||||
? '!bg-slate-100 dark:!bg-zinc-900'
|
? '!bg-slate-100 dark:!bg-zinc-900'
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
@@ -46,11 +47,11 @@
|
|||||||
profile={prof}
|
profile={prof}
|
||||||
{index}
|
{index}
|
||||||
{guest}
|
{guest}
|
||||||
selected={$profile?.id == prof.id}
|
selected={profile.data?.id == prof.id}
|
||||||
/>
|
/>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<span
|
<span
|
||||||
class="inline-flex flex-col gap-0 {$profile?.id == prof.id
|
class="inline-flex flex-col gap-0 {profile.data?.id == prof.id
|
||||||
? 'font-semibold'
|
? 'font-semibold'
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
gap-1 h-fit max-h-screen {clazz}"
|
gap-1 h-fit max-h-screen {clazz}"
|
||||||
{style}
|
{style}
|
||||||
>
|
>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<SidebarButton icon={UserCircle} href="/profile">
|
<SidebarButton icon={UserCircle} href="/profile">
|
||||||
{#snippet label()}
|
{#snippet label()}
|
||||||
<span>
|
<span>
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profileData.profiles.length >= 1}
|
{#if profileData.profiles.length >= 1}
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
|
|
||||||
<Expandable
|
<Expandable
|
||||||
@@ -103,13 +103,13 @@
|
|||||||
{$t('account.accounts')}
|
{$t('account.accounts')}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<span class="dark:text-white text-black">
|
<span class="dark:text-white text-black">
|
||||||
{$profileData.profiles.length}
|
{profileData.profiles.length}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#each [...$profileData.profiles] as prof, index}
|
{#each [...profileData.profiles] as prof, index}
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<ProfileButton {index} {prof} />
|
<ProfileButton {index} {prof} />
|
||||||
</div>
|
</div>
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
{#if $profile?.favorites && $profile?.favorites.length > 0}
|
{#if profile.data?.favorites && profile.data?.favorites.length > 0}
|
||||||
<Expandable
|
<Expandable
|
||||||
class="max-w-full min-w-0 w-full"
|
class="max-w-full min-w-0 w-full"
|
||||||
bind:open={settings.expand.favorites}
|
bind:open={settings.expand.favorites}
|
||||||
@@ -135,18 +135,18 @@
|
|||||||
{$t('routes.profile.favorites')}
|
{$t('routes.profile.favorites')}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<span class="dark:text-white text-black">
|
<span class="dark:text-white text-black">
|
||||||
{$profile.favorites?.length}
|
{profile.data.favorites?.length}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<CommunityList isFavorites items={$profile.favorites} />
|
<CommunityList isFavorites items={profile.data.favorites} />
|
||||||
</Expandable>
|
</Expandable>
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if $profile?.user}
|
{#if profile.data?.user}
|
||||||
{#if $profile?.user.moderates.length > 0}
|
{#if profile.data?.user.moderates.length > 0}
|
||||||
<Expandable
|
<Expandable
|
||||||
class="max-w-full min-w-0 w-full"
|
class="max-w-full min-w-0 w-full"
|
||||||
bind:open={settings.expand.moderates}
|
bind:open={settings.expand.moderates}
|
||||||
@@ -161,14 +161,14 @@
|
|||||||
{$t('routes.profile.moderates')}
|
{$t('routes.profile.moderates')}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<span class="dark:text-white text-black">
|
<span class="dark:text-white text-black">
|
||||||
{$profile.user?.moderates.length}
|
{profile.data.user?.moderates.length}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<CommunityList
|
<CommunityList
|
||||||
items={$profile.user.moderates.map((i) => i.community)}
|
items={profile.data.user.moderates.map((i) => i.community)}
|
||||||
/>
|
/>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
|
||||||
@@ -188,13 +188,15 @@
|
|||||||
{$t('profile.subscribed')}
|
{$t('profile.subscribed')}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<span class="dark:text-white text-black">
|
<span class="dark:text-white text-black">
|
||||||
{$profile.user?.follows.length}
|
{profile.data.user?.follows.length}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<CommunityList items={$profile.user.follows.map((i) => i.community)} />
|
<CommunityList
|
||||||
|
items={profile.data.user.follows.map((i) => i.community)}
|
||||||
|
/>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
{#snippet title()}
|
{#snippet customTitle()}
|
||||||
<span>
|
<span>
|
||||||
{#if title}{@render title()}{:else}Debug{/if}
|
{#if title}{@render title()}{:else}Debug{/if}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
+2
-14
@@ -11,16 +11,6 @@ export const site = writable<GetSiteResponse | undefined>(undefined)
|
|||||||
const isURL = (input: RequestInfo | URL): input is URL =>
|
const isURL = (input: RequestInfo | URL): input is URL =>
|
||||||
typeof input == 'object' && 'searchParams' in input
|
typeof input == 'object' && 'searchParams' in input
|
||||||
|
|
||||||
const toURL = (input: RequestInfo | URL): URL | undefined => {
|
|
||||||
if (isURL(input)) return input
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new URL(input.toString())
|
|
||||||
} catch (e) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function customFetch(
|
async function customFetch(
|
||||||
func:
|
func:
|
||||||
| ((
|
| ((
|
||||||
@@ -67,9 +57,9 @@ export function client({
|
|||||||
) => Promise<Response>
|
) => Promise<Response>
|
||||||
auth?: string
|
auth?: string
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (!instanceURL) instanceURL = get(profile).instance
|
if (!instanceURL) instanceURL = profile.data.instance
|
||||||
|
|
||||||
let jwt = auth ? auth : get(profile)?.jwt
|
let jwt = auth ? auth : profile.data?.jwt
|
||||||
|
|
||||||
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
|
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
|
||||||
|
|
||||||
@@ -91,8 +81,6 @@ export function getClient(
|
|||||||
return client({ instanceURL, func, auth })
|
return client({ instanceURL, func, auth })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInstance = () => encodeURIComponent(get(instance))
|
|
||||||
|
|
||||||
export async function validateInstance(instance: string): Promise<boolean> {
|
export async function validateInstance(instance: string): Promise<boolean> {
|
||||||
if (instance == '') return false
|
if (instance == '') return false
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export let resumables = resumableStore()
|
|||||||
|
|
||||||
export function addFavorite(item: Community, add: boolean = true) {
|
export function addFavorite(item: Community, add: boolean = true) {
|
||||||
const pd = get(profileData)
|
const pd = get(profileData)
|
||||||
const p = pd.profiles.find((p) => p.id == get(profile)?.id)
|
const p = pd.profiles.find((p) => p.id == profile.data?.id)
|
||||||
if (!p) return
|
if (!p) return
|
||||||
|
|
||||||
let favs = p.favorites ?? []
|
let favs = p.favorites ?? []
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
|
|||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export const blockUser = async (block: boolean, id: number) => {
|
export const blockUser = async (block: boolean, id: number) => {
|
||||||
const auth = get(profile)?.jwt
|
const auth = profile.data?.jwt
|
||||||
|
|
||||||
if (!auth) throw new Error('Unauthorized')
|
if (!auth) throw new Error('Unauthorized')
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export const addSubscription = (
|
|||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true,
|
subscribe: boolean = true,
|
||||||
) => {
|
) => {
|
||||||
const p = get(profile)
|
const p = profile
|
||||||
|
|
||||||
if (!p.user) return
|
if (!p.user) return
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export const addSubscription = (
|
|||||||
p.user.follows.splice(index, 1)
|
p.user.follows.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.set(p)
|
profile.data.set(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
||||||
@@ -56,4 +56,4 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const hasFavorite = (profile: Profile, id: number): boolean =>
|
export const hasFavorite = (profile: Profile, id: number): boolean =>
|
||||||
profile?.favorites?.map((i) => i.id).includes(id) ?? false
|
profile.data?.favorites?.map((i) => i.id).includes(id) ?? false
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
|
||||||
type AnyFunction = (...args: any[]) => any
|
|
||||||
|
|
||||||
export const awaitIfServer = async <T>(
|
export const awaitIfServer = async <T>(
|
||||||
promise: Promise<T>,
|
promise: Promise<T>,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import type { Community } from 'lemmy-js-client'
|
import type { Community } from 'lemmy-js-client'
|
||||||
import { writable } from 'svelte/store'
|
|
||||||
|
|
||||||
interface SessionStorage {
|
interface SessionStorage {
|
||||||
lastSeenCommunity: Community | undefined
|
lastSeenCommunity: Community | undefined
|
||||||
@@ -35,9 +34,3 @@ export const getSessionStorage = (
|
|||||||
if (!browser) return
|
if (!browser) return
|
||||||
return JSON.parse(sessionStorage.getItem(key)!)
|
return JSON.parse(sessionStorage.getItem(key)!)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Route {
|
|
||||||
title: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const route = writable<Route | undefined>(undefined)
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
{#if debugging}
|
{#if debugging}
|
||||||
<DebugObject
|
<DebugObject
|
||||||
object={debugProfile?.id == $profile?.id ? $profile : debugProfile}
|
object={debugProfile?.id == profile.data?.id ? profile : debugProfile}
|
||||||
bind:open={debugging}
|
bind:open={debugging}
|
||||||
>
|
>
|
||||||
{#snippet title()}
|
{#snippet title()}
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
</Modal>
|
</Modal>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $profileData.profiles.length == 0}
|
{#if profileData.profiles.length == 0}
|
||||||
<div class="h-max flex items-center justify-center my-auto">
|
<div class="h-max flex items-center justify-center my-auto">
|
||||||
<div
|
<div
|
||||||
class="flex flex-col justify-center items-center py-8 gap-4
|
class="flex flex-col justify-center items-center py-8 gap-4
|
||||||
@@ -158,29 +158,28 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
<div>
|
<div>
|
||||||
{#each $profileData.profiles as profile, index (profile.id)}
|
{#each profileData.profiles as profile, index}
|
||||||
<div
|
<div
|
||||||
class="flex flex-row gap-2 items-center py-3"
|
class="flex flex-row gap-2 items-center py-3"
|
||||||
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
transition:fly={{ duration: 500, y: -12, easing: expoOut }}
|
||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
title={profile.id == $currentProfile?.id ? 'Switch' : 'Current'}
|
title={profile.id == currentProfile?.data.id ? 'Switch' : 'Current'}
|
||||||
onclick={async () => {
|
onclick={async () => {
|
||||||
if (profile.id != $currentProfile?.id) {
|
if (profile.id != currentProfile?.data.id) {
|
||||||
switching = profile.id
|
switching = profile.id
|
||||||
await setUserID(profile.id)
|
await setUserID(profile.id)
|
||||||
switching = -69
|
switching = -69
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
|
color={profile.id == currentProfile?.data.id ? 'primary' : 'ghost'}
|
||||||
loading={switching == profile.id}
|
loading={switching == profile.id}
|
||||||
disabled={switching == profile.id}
|
disabled={switching == profile.id}
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
{#if profile.id == $currentProfile?.id}
|
{#if profile.id == currentProfile?.data.id}
|
||||||
<Icon src={Check} mini size="16" />
|
<Icon src={Check} mini size="16" />
|
||||||
{:else}
|
{:else}
|
||||||
<Icon src={ArrowsRightLeft} size="16" mini />
|
<Icon src={ArrowsRightLeft} size="16" mini />
|
||||||
@@ -191,7 +190,7 @@
|
|||||||
<ProfileAvatar
|
<ProfileAvatar
|
||||||
{profile}
|
{profile}
|
||||||
{index}
|
{index}
|
||||||
selected={$currentProfile?.id == profile.id}
|
selected={currentProfile?.data.id == profile.id}
|
||||||
size={24}
|
size={24}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { getClient } from '$lib/lemmy.js'
|
|||||||
import { site as siteStore } from '$lib/lemmy'
|
import { site as siteStore } from '$lib/lemmy'
|
||||||
|
|
||||||
export async function load({ fetch }) {
|
export async function load({ fetch }) {
|
||||||
if (!get(profile)) return
|
if (!profile) return
|
||||||
let { jwt } = get(profile)!
|
let { jwt } = profile!
|
||||||
let site = get(siteStore)
|
let site = get(siteStore)
|
||||||
|
|
||||||
if (!site) {
|
if (!site) {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { getClient } from '$lib/lemmy.js'
|
|||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export async function load({ data, fetch, url }) {
|
export async function load({ data, fetch, url }) {
|
||||||
if (!get(profile)) return
|
if (!profile) return
|
||||||
|
|
||||||
const { jwt } = get(profile)!
|
const { jwt } = profile.data!
|
||||||
if (!jwt) return
|
if (!jwt) return
|
||||||
|
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
let reviewing = $state(false)
|
let reviewing = $state(false)
|
||||||
|
|
||||||
async function review(approve: boolean) {
|
async function review(approve: boolean) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
let registrationApplicationAnswer: ApproveRegistrationApplication = {
|
let registrationApplicationAnswer: ApproveRegistrationApplication = {
|
||||||
approve: approve,
|
approve: approve,
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
application.creator_local_user.accepted_application = approve
|
application.creator_local_user.accepted_application = approve
|
||||||
application.admin = $profile.user!.local_user_view.person
|
application.admin = profile.data.user!.local_user_view.person
|
||||||
application.registration_application.deny_reason = denyReason
|
application.registration_application.deny_reason = denyReason
|
||||||
|
|
||||||
$notifications.applications -= 1
|
$notifications.applications -= 1
|
||||||
|
|||||||
@@ -38,10 +38,10 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
saving = true
|
saving = true
|
||||||
const { jwt } = $profile
|
const { jwt } = profile.data
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await getClient().editSite({
|
await getClient().editSite({
|
||||||
@@ -242,8 +242,8 @@
|
|||||||
</Switch>
|
</Switch>
|
||||||
|
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
|
<SectionTitle>{$t('form.profile.data.languages.title')}</SectionTitle>
|
||||||
<p>{$t('form.profile.languages.description')}</p>
|
<p>{$t('form.profile.data.languages.description')}</p>
|
||||||
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
||||||
{#if $site && formData.discussion_languages}
|
{#if $site && formData.discussion_languages}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
if (instance == '') return
|
if (instance == '') return
|
||||||
await trycatch(async () => {
|
await trycatch(async () => {
|
||||||
if (
|
if (
|
||||||
!$profile?.jwt ||
|
!profile.data?.jwt ||
|
||||||
!data.federated_instances?.federated_instances?.blocked ||
|
!data.federated_instances?.federated_instances?.blocked ||
|
||||||
!data.federated_instances?.federated_instances?.allowed
|
!data.federated_instances?.federated_instances?.allowed
|
||||||
)
|
)
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
const save = async () => {
|
const save = async () => {
|
||||||
const res = await trycatch(async () => {
|
const res = await trycatch(async () => {
|
||||||
if (
|
if (
|
||||||
!$profile?.jwt ||
|
!profile.data?.jwt ||
|
||||||
!data.federated_instances?.federated_instances?.blocked
|
!data.federated_instances?.federated_instances?.blocked
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
let saving = $state(false)
|
let saving = $state(false)
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
saving = true
|
saving = true
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
action: () => removeAdmin(id, true),
|
action: () => removeAdmin(id, true),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
const result = await trycatch(() =>
|
const result = await trycatch(() =>
|
||||||
getClient().addAdmin({
|
getClient().addAdmin({
|
||||||
@@ -75,10 +75,14 @@
|
|||||||
class="flex flex-row items-center gap-2 mt-auto w-full"
|
class="flex flex-row items-center gap-2 mt-auto w-full"
|
||||||
onsubmit={preventDefault(() => {
|
onsubmit={preventDefault(() => {
|
||||||
trycatch(async () => {
|
trycatch(async () => {
|
||||||
if (!$profile?.jwt || newAdmin == '') return
|
if (!profile.data?.jwt || newAdmin == '') return
|
||||||
adding = true
|
adding = true
|
||||||
|
|
||||||
const r = await addAdmin(`${newAdmin}@${$instance}`, true, $profile.jwt)
|
const r = await addAdmin(
|
||||||
|
`${newAdmin}@${$instance}`,
|
||||||
|
true,
|
||||||
|
profile.data.jwt,
|
||||||
|
)
|
||||||
if (!r) return
|
if (!r) return
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function addModerator() {
|
async function addModerator() {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
formData.addingModerator = true
|
formData.addingModerator = true
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function removeMod(id: number) {
|
async function removeMod(id: number) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getClient().addModToCommunity({
|
const res = await getClient().addModToCommunity({
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { getInstance } from '$lib/lemmy.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export function load({ params }) {
|
export function load({ params }) {
|
||||||
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
||||||
redirect(302, `/comment/${getInstance()}/${params.instance}`)
|
redirect(302, `/comment/${profile.data.instance}/${params.instance}`)
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
id: number | undefined = community?.community.id,
|
id: number | undefined = community?.community.id,
|
||||||
subscribed: SubscribedType | undefined = community?.subscribed,
|
subscribed: SubscribedType | undefined = community?.subscribed,
|
||||||
) {
|
) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
if (!id || !subscribed) return
|
if (!id || !subscribed) return
|
||||||
|
|
||||||
subscribing = true
|
subscribing = true
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
} = $props()
|
} = $props()
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!$profile?.jwt) {
|
if (!profile.data?.jwt) {
|
||||||
goto('/login')
|
goto('/login')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
let markingAsRead = $state(false)
|
let markingAsRead = $state(false)
|
||||||
|
|
||||||
async function markAllAsRead() {
|
async function markAllAsRead() {
|
||||||
if (!$profile?.user) {
|
if (!profile.data?.user) {
|
||||||
goto('/login')
|
goto('/login')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { get } from 'svelte/store'
|
|||||||
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
|
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
|
||||||
|
|
||||||
export async function load({ url, fetch }) {
|
export async function load({ url, fetch }) {
|
||||||
const auth = get(profile)
|
const auth = profile
|
||||||
if (!auth?.jwt) return
|
if (!auth?.jwt) return
|
||||||
|
|
||||||
const type: InboxFeedType =
|
const type: InboxFeedType =
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
async function markAsRead(isRead: boolean) {
|
async function markAsRead(isRead: boolean) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
item.read = isRead
|
item.read = isRead
|
||||||
if ($profile.user) $notifications.inbox += isRead ? -1 : 1
|
if (profile.data.user) $notifications.inbox += isRead ? -1 : 1
|
||||||
|
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
{:then data}
|
{:then data}
|
||||||
{@const conversations = data.private_messages}
|
{@const conversations = data.private_messages}
|
||||||
{@const previews = conversationPreviews(conversations).filter(
|
{@const previews = conversationPreviews(conversations).filter(
|
||||||
(c) => c.user.id != $profile?.user?.local_user_view.person.id,
|
(c) => c.user.id != profile.data?.user?.local_user_view.person.id,
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
|
|||||||
@@ -51,9 +51,6 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
data.instance = data.instance.trim()
|
data.instance = data.instance.trim()
|
||||||
// if (!(await validateInstance(data.instance))) {
|
|
||||||
// throw new Error('Failed to contact that instance. Is it down?')
|
|
||||||
// }
|
|
||||||
|
|
||||||
const response = await getClient(data.instance).login({
|
const response = await getClient(data.instance).login({
|
||||||
username_or_email: data.username.trim(),
|
username_or_email: data.username.trim(),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
let form = $state({
|
let form = $state({
|
||||||
instance: '',
|
instance: '',
|
||||||
username: `${$t('account.guest')} ${$profileData.profiles.filter((p) => p.jwt == undefined).length + 1}`,
|
username: `${$t('account.guest')} ${profileData.profiles.filter((p) => p.jwt == undefined).length + 1}`,
|
||||||
loading: false,
|
loading: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -33,21 +33,13 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
profileData.update((pd) => {
|
const id = Math.max(...profileData.profiles.map((i) => i.id)) + 1
|
||||||
// too lazy to make a decent system
|
profileData.profiles.push({
|
||||||
const id = Math.floor(Math.random() * 100000)
|
|
||||||
|
|
||||||
const newProfile: Profile = {
|
|
||||||
id: id,
|
id: id,
|
||||||
instance: form.instance,
|
instance: form.instance,
|
||||||
username: form.username,
|
username: form.username,
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
profile: id,
|
|
||||||
profiles: [...pd.profiles, newProfile],
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
profileData.profile = id
|
||||||
|
|
||||||
toast({ content: $t('toast.addAccount'), type: 'success' })
|
toast({ content: $t('toast.addAccount'), type: 'success' })
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export async function load({ url, fetch }) {
|
|||||||
const filter: ReportFilter =
|
const filter: ReportFilter =
|
||||||
(url.searchParams.get('filter') as ReportFilter) || 'all'
|
(url.searchParams.get('filter') as ReportFilter) || 'all'
|
||||||
|
|
||||||
const jwt = get(profile)?.jwt
|
const jwt = profile.data?.jwt
|
||||||
|
|
||||||
if (!jwt) return { type: type, page: page }
|
if (!jwt) return { type: type, page: page }
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export async function load({ url, fetch }) {
|
|||||||
unresolved_only: type == 'unread',
|
unresolved_only: type == 'unread',
|
||||||
}
|
}
|
||||||
|
|
||||||
const admin = get(profile)?.user ? isAdmin(get(profile)!.user!) : false
|
const admin = profile.data?.user ? isAdmin(profile!.user!) : false
|
||||||
|
|
||||||
const [posts, comments, messages] = await Promise.all([
|
const [posts, comments, messages] = await Promise.all([
|
||||||
client.listPostReports({
|
client.listPostReports({
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
let resolving = $state(false)
|
let resolving = $state(false)
|
||||||
async function resolve() {
|
async function resolve() {
|
||||||
if (!$profile?.jwt || !$profile.user) return
|
if (!profile.data?.jwt || !profile.data.user) return
|
||||||
resolving = true
|
resolving = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
type="instance"
|
type="instance"
|
||||||
placeholder="Filter by instance"
|
placeholder="Filter by instance"
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
label="Instance"
|
label="Instance"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
/>
|
/>
|
||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
placeholder="Filter by community"
|
placeholder="Filter by community"
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
label="Community"
|
label="Community"
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
instance={page.url.searchParams.get('instance') || undefined}
|
instance={page.url.searchParams.get('instance') || undefined}
|
||||||
placeholder="Filter by user"
|
placeholder="Filter by user"
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
@@ -132,10 +132,10 @@
|
|||||||
onselect={(e) =>
|
onselect={(e) =>
|
||||||
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
searchParam(page.url, 'user', e?.id.toString() ?? '', 'page')}
|
||||||
/>
|
/>
|
||||||
{#if $profile?.user && isAdmin($profile?.user)}
|
{#if profile.data?.user && isAdmin(profile.data?.user)}
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
placeholder="Filter by moderator"
|
placeholder="Filter by moderator"
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
|
|||||||
@@ -73,13 +73,13 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={password}
|
bind:value={password}
|
||||||
label={$t('form.profile.newPassword')}
|
label={$t('form.profile.data.newPassword')}
|
||||||
type="password"
|
type="password"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={password_verify}
|
bind:value={password_verify}
|
||||||
label={$t('form.profile.verifyNewPassword')}
|
label={$t('form.profile.data.verifyNewPassword')}
|
||||||
type="password"
|
type="password"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { instance } from '$lib/instance.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { getInstance } from '$lib/lemmy.js'
|
|
||||||
import { error, redirect } from '@sveltejs/kit'
|
import { error, redirect } from '@sveltejs/kit'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
@@ -7,7 +6,7 @@ export function load({ params, url }) {
|
|||||||
if (Number(params.instance)) {
|
if (Number(params.instance)) {
|
||||||
const split = url.pathname.split('/')
|
const split = url.pathname.split('/')
|
||||||
|
|
||||||
split.splice(2, 0, `${getInstance()?.toLowerCase()}`)
|
split.splice(2, 0, `${profile.data.instance?.toLowerCase()}`)
|
||||||
|
|
||||||
const newUrl = new URL(url)
|
const newUrl = new URL(url)
|
||||||
newUrl.pathname = split.join('/')
|
newUrl.pathname = split.join('/')
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (
|
if (
|
||||||
!(data.post.post_view.read && settings.markPostsAsRead) &&
|
!(data.post.post_view.read && settings.markPostsAsRead) &&
|
||||||
$profile?.jwt
|
profile.data?.jwt
|
||||||
) {
|
) {
|
||||||
getClient().markPostAsRead({
|
getClient().markPostAsRead({
|
||||||
read: settings.markPostsAsRead,
|
read: settings.markPostsAsRead,
|
||||||
@@ -237,12 +237,12 @@
|
|||||||
<span class="text-primary-900 dark:text-primary-100 font-bold">
|
<span class="text-primary-900 dark:text-primary-100 font-bold">
|
||||||
{$t('routes.post.remoteView')}
|
{$t('routes.post.remoteView')}
|
||||||
</span>
|
</span>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<Button
|
<Button
|
||||||
class="ml-auto"
|
class="ml-auto"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
if ($profile?.jwt) {
|
if (profile.data?.jwt) {
|
||||||
fetchOnHome($profile?.jwt)
|
fetchOnHome(profile.data?.jwt)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
{#if !commenting}
|
{#if !commenting}
|
||||||
<EndPlaceholder class="">
|
<EndPlaceholder class="">
|
||||||
<Button color="primary" onclick={() => (commenting = true)}>
|
<Button color="primary" onclick={() => (commenting = true)}>
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
}}
|
}}
|
||||||
locked={(post.post_view.post.locked &&
|
locked={(post.post_view.post.locked &&
|
||||||
!(
|
!(
|
||||||
$profile?.user?.local_user_view.local_user.admin ||
|
profile.data?.user?.local_user_view.local_user.admin ||
|
||||||
$profile?.user?.moderates
|
profile.data?.user?.moderates
|
||||||
.map((c) => c.community.id)
|
.map((c) => c.community.id)
|
||||||
.includes(post.community_view.community.id)
|
.includes(post.community_view.community.id)
|
||||||
)) ||
|
)) ||
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if commenting || !$profile.jwt}
|
{#if commenting || !profile.data.jwt}
|
||||||
<div class="gap-2 flex items-center">
|
<div class="gap-2 flex items-center">
|
||||||
<Select size="md" bind:value={sort} onchange={onupdate}>
|
<Select size="md" bind:value={sort} onchange={onupdate}>
|
||||||
<Option icon={Fire} value="Hot">{$t('filter.sort.hot')}</Option>
|
<Option icon={Fire} value="Hot">{$t('filter.sort.hot')}</Option>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
let data = $state(pageData)
|
let data = $state(pageData)
|
||||||
|
|
||||||
async function unblockUser(item: PersonBlockView) {
|
async function unblockUser(item: PersonBlockView) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
data.person_blocks.splice(
|
data.person_blocks.splice(
|
||||||
data.person_blocks.findIndex((i) => i.target.id == item.target.id),
|
data.person_blocks.findIndex((i) => i.target.id == item.target.id),
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function unblockCommunity(item: CommunityBlockView) {
|
async function unblockCommunity(item: CommunityBlockView) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
data.community_blocks.splice(
|
data.community_blocks.splice(
|
||||||
data.community_blocks.findIndex(
|
data.community_blocks.findIndex(
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function unblockInstances(item: InstanceBlockView) {
|
async function unblockInstances(item: InstanceBlockView) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
if (!data.my_user?.instance_blocks) return
|
if (!data.my_user?.instance_blocks) return
|
||||||
|
|
||||||
data.my_user.instance_blocks.splice(
|
data.my_user.instance_blocks.splice(
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
url: '/profile/password',
|
url: '/profile/password',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: $t('form.profile.2fa.2fa'),
|
name: $t('form.profile.data.2fa.2fa'),
|
||||||
url: '/profile/password/2fa',
|
url: '/profile/password/2fa',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
>
|
>
|
||||||
<Icon src={Key} size="24" />
|
<Icon src={Key} size="24" />
|
||||||
</Material>
|
</Material>
|
||||||
<span class="font-medium text-lg">{$t('form.profile.2fa.2fa')}</span>
|
<span class="font-medium text-lg">{$t('form.profile.data.2fa.2fa')}</span>
|
||||||
<span class="text-sm">
|
<span class="text-sm">
|
||||||
{data.my_user?.local_user_view.local_user.totp_2fa_enabled
|
{data.my_user?.local_user_view.local_user.totp_2fa_enabled
|
||||||
? $t('common.enabled')
|
? $t('common.enabled')
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
disabled
|
disabled
|
||||||
type="password"
|
type="password"
|
||||||
value={totpLink}
|
value={totpLink}
|
||||||
label={$t('form.profile.2fa.totp')}
|
label={$t('form.profile.data.2fa.totp')}
|
||||||
>
|
>
|
||||||
{#snippet suffix()}
|
{#snippet suffix()}
|
||||||
<button
|
<button
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<span class="font-normal text-xs">
|
<span class="font-normal text-xs">
|
||||||
{$t('form.profile.2fa.paste')}
|
{$t('form.profile.data.2fa.paste')}
|
||||||
</span>
|
</span>
|
||||||
</TextInput>
|
</TextInput>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
old_password: oldPassword,
|
old_password: oldPassword,
|
||||||
})
|
})
|
||||||
if (res?.jwt) {
|
if (res?.jwt) {
|
||||||
const { instance, username } = $profile
|
const { instance, username } = profile.data
|
||||||
deleteProfile($profile.id)
|
deleteProfile(profile.data.id)
|
||||||
await setUser(res.jwt, instance, username!)
|
await setUser(res.jwt, instance, username!)
|
||||||
$currentInstance = instance
|
$currentInstance = instance
|
||||||
|
|
||||||
@@ -47,21 +47,21 @@
|
|||||||
<form onsubmit={preventDefault(changePassword)} class="flex flex-col gap-4">
|
<form onsubmit={preventDefault(changePassword)} class="flex flex-col gap-4">
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={oldPassword}
|
bind:value={oldPassword}
|
||||||
label={$t('form.profile.currentPassword')}
|
label={$t('form.profile.data.currentPassword')}
|
||||||
type="password"
|
type="password"
|
||||||
minlength={10}
|
minlength={10}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={newPassword}
|
bind:value={newPassword}
|
||||||
label={$t('form.profile.newPassword')}
|
label={$t('form.profile.data.newPassword')}
|
||||||
type="password"
|
type="password"
|
||||||
minlength={10}
|
minlength={10}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={newPasswordVerify}
|
bind:value={newPasswordVerify}
|
||||||
label={$t('form.profile.verifyNewPassword')}
|
label={$t('form.profile.data.verifyNewPassword')}
|
||||||
type="password"
|
type="password"
|
||||||
minlength={10}
|
minlength={10}
|
||||||
required
|
required
|
||||||
|
|||||||
@@ -70,15 +70,10 @@
|
|||||||
delete_content: deletion.deleteContent,
|
delete_content: deletion.deleteContent,
|
||||||
})
|
})
|
||||||
|
|
||||||
profileData.update((pd) => {
|
profileData.profiles.splice(
|
||||||
pd.profiles.splice(
|
profileData.profiles.findIndex((p) => profileData.profile == p.id),
|
||||||
pd.profiles.findIndex((p) => pd.profile == p.id),
|
|
||||||
1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return pd
|
|
||||||
})
|
|
||||||
|
|
||||||
setUserID(-1)
|
setUserID(-1)
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.deleted'),
|
content: $t('toast.deleted'),
|
||||||
@@ -102,7 +97,7 @@
|
|||||||
onaction={() => deleteAccount(4)}
|
onaction={() => deleteAccount(4)}
|
||||||
>
|
>
|
||||||
{#snippet customTitle()}
|
{#snippet customTitle()}
|
||||||
<span>{$t('form.profile.deleteAccount.label')}</span>
|
<span>{$t('form.profile.data.deleteAccount.label')}</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<TextInput
|
<TextInput
|
||||||
label={$t('form.password')}
|
label={$t('form.password')}
|
||||||
@@ -110,10 +105,10 @@
|
|||||||
bind:value={deletion.password}
|
bind:value={deletion.password}
|
||||||
/>
|
/>
|
||||||
<Checkbox bind:checked={deletion.deleteContent}>
|
<Checkbox bind:checked={deletion.deleteContent}>
|
||||||
{$t('form.profile.deleteAccount.deleteContent')}
|
{$t('form.profile.data.deleteAccount.deleteContent')}
|
||||||
{#snippet description()}
|
{#snippet description()}
|
||||||
<span>
|
<span>
|
||||||
{$t('form.profile.deleteAccount.warning')}
|
{$t('form.profile.data.deleteAccount.warning')}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
@@ -133,10 +128,10 @@
|
|||||||
{$t('routes.profile.delete.warning')}
|
{$t('routes.profile.delete.warning')}
|
||||||
</p>
|
</p>
|
||||||
<Switch bind:checked={deletion.deleteContent}>
|
<Switch bind:checked={deletion.deleteContent}>
|
||||||
{$t('form.profile.deleteAccount.deleteContent')}
|
{$t('form.profile.data.deleteAccount.deleteContent')}
|
||||||
{#snippet description()}
|
{#snippet description()}
|
||||||
<span>
|
<span>
|
||||||
{$t('form.profile.deleteAccount.warning')}
|
{$t('form.profile.data.deleteAccount.warning')}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -40,17 +40,25 @@
|
|||||||
let bannerImage: FileList | undefined = $state()
|
let bannerImage: FileList | undefined = $state()
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
if (!formData || !$profile?.jwt) return
|
if (!formData || !profile.data?.jwt) return
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let pfp = profileImage
|
let pfp = profileImage
|
||||||
? await uploadImage(profileImage[0], $profile.instance, $profile.jwt)
|
? await uploadImage(
|
||||||
|
profileImage[0],
|
||||||
|
profile.data.instance,
|
||||||
|
profile.data.jwt,
|
||||||
|
)
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
let banner = bannerImage
|
let banner = bannerImage
|
||||||
? await uploadImage(bannerImage[0], $profile.instance, $profile.jwt)
|
? await uploadImage(
|
||||||
|
bannerImage[0],
|
||||||
|
profile.data.instance,
|
||||||
|
profile.data.jwt,
|
||||||
|
)
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
const res = await getClient().saveUserSettings({
|
const res = await getClient().saveUserSettings({
|
||||||
@@ -81,45 +89,54 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{#if data.my_user?.local_user_view?.local_user && formData}
|
{#if data.my_user?.local_user_view?.local_user && formData}
|
||||||
<TextInput label={$t('form.profile.email')} bind:value={formData.email} />
|
|
||||||
<TextInput
|
<TextInput
|
||||||
label={$t('form.profile.displayName')}
|
label={$t('form.profile.data.email')}
|
||||||
|
bind:value={formData.email}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={$t('form.profile.data.displayName')}
|
||||||
bind:value={formData.display_name}
|
bind:value={formData.display_name}
|
||||||
placeholder="Optional"
|
placeholder="Optional"
|
||||||
/>
|
/>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
images={false}
|
images={false}
|
||||||
bind:value={() => formData.bio ?? '', (v) => (formData.bio = v)}
|
bind:value={() => formData.bio ?? '', (v) => (formData.bio = v)}
|
||||||
label={$t('form.profile.bio')}
|
label={$t('form.profile.data.bio')}
|
||||||
previewButton
|
previewButton
|
||||||
/>
|
/>
|
||||||
<div class="flex gap-2 items-center *:flex-1">
|
<div class="flex gap-2 items-center *:flex-1">
|
||||||
<ImageInput label={$t('form.profile.avatar')} bind:files={profileImage} />
|
<ImageInput
|
||||||
<ImageInput label={$t('form.profile.banner')} bind:files={bannerImage} />
|
label={$t('form.profile.data.avatar')}
|
||||||
|
bind:files={profileImage}
|
||||||
|
/>
|
||||||
|
<ImageInput
|
||||||
|
label={$t('form.profile.data.banner')}
|
||||||
|
bind:files={bannerImage}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<TextInput
|
<TextInput
|
||||||
label={$t('form.profile.matrix')}
|
label={$t('form.profile.data.matrix')}
|
||||||
bind:value={formData.matrix_user_id}
|
bind:value={formData.matrix_user_id}
|
||||||
placeholder="@user:example.com"
|
placeholder="@user:example.com"
|
||||||
/>
|
/>
|
||||||
<Switch bind:checked={formData.show_nsfw}>
|
<Switch bind:checked={formData.show_nsfw}>
|
||||||
{$t('form.profile.showNSFW')}
|
{$t('form.profile.data.showNSFW')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<Switch bind:checked={formData.show_scores}>
|
<Switch bind:checked={formData.show_scores}>
|
||||||
{$t('form.profile.scores')}
|
{$t('form.profile.data.scores')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<Switch bind:checked={formData.bot_account}>
|
<Switch bind:checked={formData.bot_account}>
|
||||||
{$t('form.profile.bot')}
|
{$t('form.profile.data.bot')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<Switch bind:checked={formData.show_bot_accounts}>
|
<Switch bind:checked={formData.show_bot_accounts}>
|
||||||
{$t('form.profile.showBots')}
|
{$t('form.profile.data.showBots')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<Switch bind:checked={formData.show_read_posts}>
|
<Switch bind:checked={formData.show_read_posts}>
|
||||||
{$t('form.profile.showRead')}
|
{$t('form.profile.data.showRead')}
|
||||||
</Switch>
|
</Switch>
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
|
<SectionTitle>{$t('form.profile.data.languages.title')}</SectionTitle>
|
||||||
<p>{$t('form.profile.languages.description')}</p>
|
<p>{$t('form.profile.data.languages.description')}</p>
|
||||||
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
|
||||||
{#if $site && formData.discussion_languages}
|
{#if $site && formData.discussion_languages}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ export let ssr = false
|
|||||||
|
|
||||||
export async function load({ params, url, fetch }) {
|
export async function load({ params, url, fetch }) {
|
||||||
const my_user =
|
const my_user =
|
||||||
// get(profile)?.user ??
|
// profile.data?.user ??
|
||||||
(await client({ auth: get(profile)?.jwt, func: fetch }).getSite()).my_user
|
(await client({ auth: profile.data?.jwt, func: fetch }).getSite()).my_user
|
||||||
|
|
||||||
return {
|
return {
|
||||||
my_user: my_user,
|
my_user: my_user,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { error } from '@sveltejs/kit'
|
|||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export async function load({ fetch, url }) {
|
export async function load({ fetch, url }) {
|
||||||
const { jwt } = get(profile)
|
const { jwt } = profile.data
|
||||||
|
|
||||||
let page = Number(url.searchParams.get('page')) || 1
|
let page = Number(url.searchParams.get('page')) || 1
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
async function deleteImage(image: LocalImage) {
|
async function deleteImage(image: LocalImage) {
|
||||||
if (!$profile?.jwt) return
|
if (!profile.data?.jwt) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading = true
|
loading = true
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function getSavedItemPublished(item: PostView | CommentView) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function load({ url, fetch }) {
|
export async function load({ url, fetch }) {
|
||||||
if (!get(profile)) return { posts: [], page: 0 }
|
if (!profile) return { posts: [], page: 0 }
|
||||||
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'
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
<div transition:slide={{ axis: 'y', easing: expoOut }} class="max-w-sm">
|
<div transition:slide={{ axis: 'y', easing: expoOut }} class="max-w-sm">
|
||||||
<ObjectAutocomplete
|
<ObjectAutocomplete
|
||||||
label={$t('nav.create.community')}
|
label={$t('nav.create.community')}
|
||||||
jwt={$profile?.jwt}
|
jwt={profile.data?.jwt}
|
||||||
listing_type={'All'}
|
listing_type={'All'}
|
||||||
showWhenEmpty={true}
|
showWhenEmpty={true}
|
||||||
onselect={(c) =>
|
onselect={(c) =>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export async function load({ url, fetch }) {
|
|||||||
query: query,
|
query: query,
|
||||||
results: everything,
|
results: everything,
|
||||||
streamed: {
|
streamed: {
|
||||||
object: get(profile)?.jwt
|
object: profile.data?.jwt
|
||||||
? getClient(undefined, fetch).resolveObject({
|
? getClient(undefined, fetch).resolveObject({
|
||||||
q: query,
|
q: query,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -197,7 +197,7 @@
|
|||||||
class="flex flex-col *:py-2 divide-y divide-slate-200 dark:divide-zinc-800"
|
class="flex flex-col *:py-2 divide-y divide-slate-200 dark:divide-zinc-800"
|
||||||
style="scroll-behavior: smooth;"
|
style="scroll-behavior: smooth;"
|
||||||
>
|
>
|
||||||
{#if $profile?.jwt}
|
{#if profile.data?.jwt}
|
||||||
<Section open={false} id="account" title={$t('settings.account.title')}>
|
<Section open={false} id="account" title={$t('settings.account.title')}>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -201,7 +201,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Checkbox bind:checked={nsfw}>{$t('form.profile.showNSFW')}</Checkbox>
|
<Checkbox bind:checked={nsfw}>{$t('form.profile.data.showNSFW')}</Checkbox>
|
||||||
<input type="dn" name="honeypot" bind:value={honeypot} class="hidden" />
|
<input type="dn" name="honeypot" bind:value={honeypot} class="hidden" />
|
||||||
<Button
|
<Button
|
||||||
submit
|
submit
|
||||||
|
|||||||
@@ -51,11 +51,12 @@
|
|||||||
let blocking = false
|
let blocking = false
|
||||||
|
|
||||||
async function blockUser(block: number) {
|
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
|
blocking = true
|
||||||
try {
|
try {
|
||||||
const blocked = isBlocked($profile.user, block)
|
const blocked = isBlocked(profile.data.user, block)
|
||||||
|
|
||||||
await getClient().blockPerson({
|
await getClient().blockPerson({
|
||||||
block: !blocked,
|
block: !blocked,
|
||||||
@@ -63,10 +64,10 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (blocked) {
|
if (blocked) {
|
||||||
const index = $profile.user.person_blocks
|
const index = profile.data.user.person_blocks
|
||||||
.map((p) => p.target.id)
|
.map((p) => p.target.id)
|
||||||
.indexOf(block)
|
.indexOf(block)
|
||||||
$profile.user.person_blocks.splice(index, 1)
|
profile.data.user.person_blocks.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
@@ -209,7 +210,7 @@
|
|||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
{#snippet actions()}
|
{#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">
|
<div class="flex items-center gap-2 w-full">
|
||||||
<Button
|
<Button
|
||||||
size="square-md"
|
size="square-md"
|
||||||
@@ -234,7 +235,7 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if isAdmin($profile?.user)}
|
{#if isAdmin(profile.data?.user)}
|
||||||
<Menu class="ml-auto" placement="bottom-end">
|
<Menu class="ml-auto" placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<Button size="square-md">
|
<Button size="square-md">
|
||||||
@@ -280,7 +281,7 @@
|
|||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon mini size="16" src={NoSymbol} />
|
<Icon mini size="16" src={NoSymbol} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{isBlocked($profile.user, data.person_view.person.id)
|
{isBlocked(profile.data.user, data.person_view.person.id)
|
||||||
? 'Unblock'
|
? 'Unblock'
|
||||||
: 'Block'}
|
: 'Block'}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
|
|
||||||
let link = $state('')
|
let link = $state('')
|
||||||
|
|
||||||
let photonified
|
let photonified = $derived(photonify(link))
|
||||||
run(() => {
|
|
||||||
photonified = photonify(link)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1 class="font-bold text-2xl">Photonify links</h1>
|
<h1 class="font-bold text-2xl">Photonify links</h1>
|
||||||
@@ -21,5 +18,5 @@
|
|||||||
bind:value={link}
|
bind:value={link}
|
||||||
placeholder="https://lemmy.world/post/1"
|
placeholder="https://lemmy.world/post/1"
|
||||||
/>
|
/>
|
||||||
<TextInput label="Output" bind:value={photonified} />
|
<TextInput label="Output" value={photonified} />
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user