* cleanup: postactions styling * misc: fix first round of errors * pkg: remove vitest * fix: fix lint errors stage 2 * fix: fix lint errors stage 3 * fix: fix lint errors, stage 3 * misc: update eslint rules to warn for writable derived
105 lines
3.1 KiB
Svelte
105 lines
3.1 KiB
Svelte
<script lang="ts">
|
|
import { goto } from '$app/navigation'
|
|
import { resolveRoute } from '$app/paths'
|
|
import { page } from '$app/state'
|
|
import { profile, profileData } from '$lib/auth.svelte'
|
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
|
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
|
|
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
|
import { t } from '$lib/i18n/translations'
|
|
import { client } from '$lib/lemmy.svelte'
|
|
import { errorMessage } from '$lib/lemmy/error'
|
|
import { toast } from 'mono-svelte'
|
|
import Button from 'mono-svelte/button/Button.svelte'
|
|
import Material from 'mono-svelte/materials/Material.svelte'
|
|
import { Plus } from 'svelte-hero-icons'
|
|
|
|
let loading = $state(false)
|
|
const fetched = $state.snapshot(profile.data.instance)
|
|
|
|
async function fetchOnHome() {
|
|
loading = true
|
|
try {
|
|
const res = await client().resolveObject({
|
|
q: `https://${page.params.instance}/comment/${page.params.id}`,
|
|
})
|
|
|
|
if (res.comment) {
|
|
goto(
|
|
resolveRoute(`/comment/[instance]/[id]`, {
|
|
instance: profile.data.instance,
|
|
id: res.comment.comment.id.toString(),
|
|
}),
|
|
)
|
|
}
|
|
} catch (err) {
|
|
toast({ content: errorMessage(err), type: 'error' })
|
|
}
|
|
loading = false
|
|
}
|
|
</script>
|
|
|
|
<div class="w-full h-full flex flex-col justify-center mx-auto max-w-xl gap-6">
|
|
<header class="space-y-1">
|
|
<div class="font-mono bg-zinc-950 rounded-xs p-0.5 px-1 w-max">
|
|
{page.params.instance}/comment/{page.params.id}
|
|
</div>
|
|
<Header>
|
|
{$t('routes.postRedirect.title')}
|
|
</Header>
|
|
<p>
|
|
{$t('routes.postRedirect.description', {
|
|
homeInstance: fetched,
|
|
})}
|
|
</p>
|
|
</header>
|
|
<div class="flex flex-row items-center gap-2 flex-wrap">
|
|
{#if profile.data.jwt}
|
|
<Button
|
|
{loading}
|
|
disabled={loading}
|
|
size="md"
|
|
rounding="pill"
|
|
color="primary"
|
|
onclick={fetchOnHome}
|
|
>
|
|
{$t('routes.postRedirect.actions.fetch', {
|
|
homeInstance: fetched,
|
|
})}
|
|
</Button>
|
|
{/if}
|
|
<Button size="md" rounding="pill" onclick={() => history.back()}>
|
|
{$t('routes.postRedirect.actions.back')}
|
|
</Button>
|
|
</div>
|
|
{#if profileData.profiles}
|
|
{@const filtered = profileData.profiles.filter(
|
|
i => i.instance == page.params.instance,
|
|
)}
|
|
<div class="space-y-1">
|
|
<div class="font-medium text-sm">
|
|
{$t('routes.postRedirect.actions.switch', {
|
|
destInstance: page.params.instance,
|
|
})}
|
|
</div>
|
|
<Material
|
|
color="uniform"
|
|
padding="sm"
|
|
rounding="2xl"
|
|
class="dark:bg-zinc-950 max-h-96 overflow-auto"
|
|
>
|
|
{#each filtered as profile, index (profile.id)}
|
|
<ProfileButton prof={profile} {index} />
|
|
{/each}
|
|
<SidebarButton
|
|
href="/accounts/login/guest?redirect={page.url}"
|
|
icon={Plus}
|
|
class="rounded-lg"
|
|
>
|
|
{$t('account.addGuest')}
|
|
</SidebarButton>
|
|
</Material>
|
|
</div>
|
|
{/if}
|
|
</div>
|