cleanup: use ReactiveState to provide $state with sveltekit (#492)
This commit is contained in:
1 parent
589db4dcc7
commit
7c46e616f8
18 files changed
+168
-168
No files matched your search
@@ -29,7 +29,7 @@ export const addSubscription = (
|
|||||||
if (subscribe && index == -1) {
|
if (subscribe && index == -1) {
|
||||||
profile.data.user?.follows.push({
|
profile.data.user?.follows.push({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
follower: p.user.follows[0]?.follower,
|
follower: profile.data.user.follows[0]?.follower,
|
||||||
community: community,
|
community: community,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,3 +7,11 @@ export const awaitIfServer = async <T>(
|
|||||||
): Promise<{
|
): Promise<{
|
||||||
data: Promise<T> | T
|
data: Promise<T> | T
|
||||||
}> => ({ data: browser ? promise : await promise })
|
}> => ({ data: browser ? promise : await promise })
|
||||||
|
|
||||||
|
export class ReactiveState<T> {
|
||||||
|
value = $state<T>()!
|
||||||
|
|
||||||
|
constructor(initialValue: T) {
|
||||||
|
this.value = initialValue as NonNullable<T>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,16 +3,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{data.community.community_view.community.title}</title>
|
<title>{data.community.value.community_view.community.title}</title>
|
||||||
|
|
||||||
<meta
|
<meta
|
||||||
name="og:title"
|
name="og:title"
|
||||||
content={data.community.community_view.community.title}
|
content={data.community.value.community_view.community.title}
|
||||||
/>
|
/>
|
||||||
{#if data.community.community_view.community.description}
|
{#if data.community.value.community_view.community.description}
|
||||||
<meta
|
<meta
|
||||||
name="og:description"
|
name="og:description"
|
||||||
content={data.community.community_view.community.description}
|
content={data.community.value.community_view.community.description}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
|
import { ReactiveState } from '$lib/promise.svelte'
|
||||||
|
|
||||||
export async function load(req: any) {
|
export async function load(req: any) {
|
||||||
const community = await getClient(undefined, req.fetch).getCommunity({
|
const community = await getClient(undefined, req.fetch).getCommunity({
|
||||||
@@ -7,7 +8,7 @@ export async function load(req: any) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
community: community,
|
community: new ReactiveState(community),
|
||||||
slots: {
|
slots: {
|
||||||
sidebar: {
|
sidebar: {
|
||||||
component: CommunityCard,
|
component: CommunityCard,
|
||||||
|
|||||||
@@ -21,11 +21,7 @@
|
|||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
|
|
||||||
let { data: pageData } = $props()
|
let { data } = $props()
|
||||||
let data = $state(pageData)
|
|
||||||
$effect(() => {
|
|
||||||
data = pageData
|
|
||||||
})
|
|
||||||
|
|
||||||
let sidebar: boolean = $state(false)
|
let sidebar: boolean = $state(false)
|
||||||
|
|
||||||
@@ -33,14 +29,14 @@
|
|||||||
if (browser)
|
if (browser)
|
||||||
setSessionStorage(
|
setSessionStorage(
|
||||||
'lastSeenCommunity',
|
'lastSeenCommunity',
|
||||||
data.community.community_view.community,
|
data.community.value.community_view.community,
|
||||||
)
|
)
|
||||||
|
|
||||||
resumables.add({
|
resumables.add({
|
||||||
name: data.community.community_view.community.title,
|
name: data.community.value.community_view.community.title,
|
||||||
type: 'community',
|
type: 'community',
|
||||||
url: page.url.toString(),
|
url: page.url.toString(),
|
||||||
avatar: data.community.community_view.community.icon,
|
avatar: data.community.value.community_view.community.icon,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -60,8 +56,8 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
<div>
|
<div>
|
||||||
<CommunityCard
|
<CommunityCard
|
||||||
bind:community_view={data.community.community_view}
|
bind:community_view={data.community.value.community_view}
|
||||||
moderators={data.community.moderators}
|
moderators={data.community.value.moderators}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -71,11 +67,11 @@
|
|||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<CommunityHeader
|
<CommunityHeader
|
||||||
bind:community={data.community.community_view.community}
|
bind:community={data.community.value.community_view.community}
|
||||||
bind:subscribed={data.community.community_view.subscribed}
|
bind:subscribed={data.community.value.community_view.subscribed}
|
||||||
blocked={data.community.community_view.blocked}
|
blocked={data.community.value.community_view.blocked}
|
||||||
moderators={data.community.moderators}
|
moderators={data.community.value.moderators}
|
||||||
counts={data.community.community_view.counts}
|
counts={data.community.value.community_view.counts}
|
||||||
class="w-full relative"
|
class="w-full relative"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,7 +81,7 @@
|
|||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
{#if profile.data.user}
|
{#if profile.data.user}
|
||||||
{#if !data.community.discussion_languages.every( (l) => profile.data.user?.discussion_languages.includes(l), ) && profile.data.user.discussion_languages.length > 0}
|
{#if !data.community.value.discussion_languages.every( (l) => profile.data.user?.discussion_languages.includes(l), ) && profile.data.user.discussion_languages.length > 0}
|
||||||
<Note class="!p-1 !pl-3 flex-col md:flex-row">
|
<Note class="!p-1 !pl-3 flex-col md:flex-row">
|
||||||
{$t('routes.community.languageWarning')}
|
{$t('routes.community.languageWarning')}
|
||||||
<Button
|
<Button
|
||||||
@@ -104,7 +100,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if data.community.community_view.blocked}
|
{#if data.community.value.community_view.blocked}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={XMark}
|
icon={XMark}
|
||||||
title="Blocked"
|
title="Blocked"
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
let communityUrl = $derived(
|
let communityUrl = $derived(
|
||||||
`/c/${fullCommunityName(
|
`/c/${fullCommunityName(
|
||||||
data.community.community_view.community.name,
|
data.community.value.community_view.community.name,
|
||||||
data.community.community_view.community.actor_id,
|
data.community.value.community_view.community.actor_id,
|
||||||
)}`,
|
)}`,
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -10,23 +10,26 @@
|
|||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
<span>Settings</span>
|
<span>Settings</span>
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
<CommunityTitle community={data.community.community_view.community} />
|
<CommunityTitle
|
||||||
|
community={data.community.value.community_view.community}
|
||||||
|
/>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
<CommunityForm
|
<CommunityForm
|
||||||
edit={data.community.community_view.community.id}
|
edit={data.community.value.community_view.community.id}
|
||||||
formData={{
|
formData={{
|
||||||
name: data.community.community_view.community.name,
|
name: data.community.value.community_view.community.name,
|
||||||
displayName: data.community.community_view.community.title,
|
displayName: data.community.value.community_view.community.title,
|
||||||
nsfw: data.community.community_view.community.nsfw,
|
nsfw: data.community.value.community_view.community.nsfw,
|
||||||
postsLockedToModerators:
|
postsLockedToModerators:
|
||||||
data.community.community_view.community.posting_restricted_to_mods,
|
data.community.value.community_view.community
|
||||||
sidebar: data.community.community_view.community.description ?? '',
|
.posting_restricted_to_mods,
|
||||||
icon: data.community.community_view.community.icon,
|
sidebar: data.community.value.community_view.community.description ?? '',
|
||||||
banner: data.community.community_view.community.banner,
|
icon: data.community.value.community_view.community.icon,
|
||||||
visibility: data.community.community_view.community.visibility,
|
banner: data.community.value.community_view.community.banner,
|
||||||
|
visibility: data.community.value.community_view.community.visibility,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
languages: data.community.discussion_languages,
|
languages: data.community.value.discussion_languages,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet formtitle()}
|
{#snippet formtitle()}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
data: PageData
|
data: PageData
|
||||||
}
|
}
|
||||||
|
|
||||||
let { data: pageData }: Props = $props()
|
let { data }: Props = $props()
|
||||||
let data = $state(pageData)
|
|
||||||
|
|
||||||
let formData = $state({
|
let formData = $state({
|
||||||
newModerator: '',
|
newModerator: '',
|
||||||
@@ -33,10 +32,10 @@
|
|||||||
const addModRes = await getClient().addModToCommunity({
|
const addModRes = await getClient().addModToCommunity({
|
||||||
added: true,
|
added: true,
|
||||||
person_id: Number(formData.newModerator),
|
person_id: Number(formData.newModerator),
|
||||||
community_id: data.community.community_view.community.id,
|
community_id: data.community.value.community_view.community.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
data.community.moderators = addModRes.moderators
|
data.community.value.moderators = addModRes.moderators
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.addMod'),
|
content: $t('toast.addMod'),
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -52,10 +51,10 @@
|
|||||||
const addModRes = await getClient().addModToCommunity({
|
const addModRes = await getClient().addModToCommunity({
|
||||||
added: true,
|
added: true,
|
||||||
person_id: res.person.person.id,
|
person_id: res.person.person.id,
|
||||||
community_id: data.community.community_view.community.id,
|
community_id: data.community.value.community_view.community.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
data.community.moderators = addModRes.moderators
|
data.community.value.moderators = addModRes.moderators
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.addMod'),
|
content: $t('toast.addMod'),
|
||||||
@@ -86,11 +85,11 @@
|
|||||||
try {
|
try {
|
||||||
const res = await getClient().addModToCommunity({
|
const res = await getClient().addModToCommunity({
|
||||||
added: false,
|
added: false,
|
||||||
community_id: data.community.community_view.community.id,
|
community_id: data.community.value.community_view.community.id,
|
||||||
person_id: id,
|
person_id: id,
|
||||||
})
|
})
|
||||||
|
|
||||||
data.community.moderators = res.moderators
|
data.community.value.moderators = res.moderators
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
content: $t('toast.updateMods'),
|
content: $t('toast.updateMods'),
|
||||||
@@ -107,7 +106,7 @@
|
|||||||
|
|
||||||
<Header pageHeader>Moderators</Header>
|
<Header pageHeader>Moderators</Header>
|
||||||
<ul class="divide-y divide-slate-200 dark:divide-zinc-800">
|
<ul class="divide-y divide-slate-200 dark:divide-zinc-800">
|
||||||
{#each data.community.moderators as moderator (moderator.moderator.id)}
|
{#each data.community.value.moderators as moderator (moderator.moderator.id)}
|
||||||
<div
|
<div
|
||||||
class="py-4 flex items-center gap-2 justify-between"
|
class="py-4 flex items-center gap-2 justify-between"
|
||||||
animate:flip={{ duration: 300 }}
|
animate:flip={{ duration: 300 }}
|
||||||
|
|||||||
@@ -34,17 +34,14 @@
|
|||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
let communities = $state(data.communities)
|
|
||||||
$effect(() => {
|
|
||||||
communities = data.communities
|
|
||||||
})
|
|
||||||
|
|
||||||
let search = $state(data.query || '')
|
let search = $state(data.query || '')
|
||||||
let searchElement = $state<HTMLInputElement>()
|
let searchElement = $state<HTMLInputElement>()
|
||||||
let form = $state<HTMLFormElement>()
|
let form = $state<HTMLFormElement>()
|
||||||
|
|
||||||
let showTop = $derived(
|
let showTop = $derived(
|
||||||
(data.query ?? '' != '') && data.communities.length > 0 && data.page == 1,
|
(data.query ?? '' != '') &&
|
||||||
|
data.communities.value.length > 0 &&
|
||||||
|
data.page == 1,
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -124,7 +121,7 @@
|
|||||||
<ul
|
<ul
|
||||||
class="flex flex-col divide-y divide-slate-100 dark:divide-zinc-800 my-6 h-full"
|
class="flex flex-col divide-y divide-slate-100 dark:divide-zinc-800 my-6 h-full"
|
||||||
>
|
>
|
||||||
{#if communities.length == 0}
|
{#if data.communities.value.length == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={QuestionMarkCircle}
|
icon={QuestionMarkCircle}
|
||||||
title={$t('routes.search.noResults.title')}
|
title={$t('routes.search.noResults.title')}
|
||||||
@@ -139,7 +136,7 @@
|
|||||||
<div
|
<div
|
||||||
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
|
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
|
||||||
>
|
>
|
||||||
{#each communities.slice(0, 3) as community, index (community.community.id)}
|
{#each data.communities.value.slice(0, 3) as community, index (community.community.id)}
|
||||||
<div
|
<div
|
||||||
class="h-full"
|
class="h-full"
|
||||||
in:fly|global={{
|
in:fly|global={{
|
||||||
@@ -167,13 +164,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if communities.slice(showTop ? 3 : 0).length > 0}
|
{#if data.communities.value.slice(showTop ? 3 : 0).length > 0}
|
||||||
<SectionTitle class="!border-0 pb-2">
|
<SectionTitle class="!border-0 pb-2">
|
||||||
{$t('routes.search.other')}
|
{$t('routes.search.other')}
|
||||||
</SectionTitle>
|
</SectionTitle>
|
||||||
{/if}
|
{/if}
|
||||||
{#if communities}
|
{#if data.communities.value}
|
||||||
{@const sliced = communities.slice(showTop ? 3 : 0)}
|
{@const sliced = data.communities.value.slice(showTop ? 3 : 0)}
|
||||||
<div class="-mx-4 sm:-mx-6 h-full">
|
<div class="-mx-4 sm:-mx-6 h-full">
|
||||||
{#each sliced as community, index (community.community.id)}
|
{#each sliced as community, index (community.community.id)}
|
||||||
<div
|
<div
|
||||||
@@ -193,7 +190,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
{#if communities.length > 0}
|
{#if data.communities.value.length > 0}
|
||||||
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Tabs routes={[]} class="mx-auto">
|
||||||
<Pageination
|
<Pageination
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte.js'
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte.js'
|
||||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||||
|
import { ReactiveState } from '$lib/promise.svelte'
|
||||||
import {
|
import {
|
||||||
type ListCommunitiesResponse,
|
type ListCommunitiesResponse,
|
||||||
type ListingType,
|
type ListingType,
|
||||||
@@ -35,7 +36,7 @@ export async function load({ url, fetch }) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...communities,
|
communities: new ReactiveState(communities.communities),
|
||||||
type: type,
|
type: type,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
query: query,
|
query: query,
|
||||||
|
|||||||
@@ -26,11 +26,6 @@
|
|||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
let inbox = $state(data.data)
|
|
||||||
$effect(() => {
|
|
||||||
inbox = data.data
|
|
||||||
})
|
|
||||||
|
|
||||||
let markingAsRead = $state(false)
|
let markingAsRead = $state(false)
|
||||||
|
|
||||||
async function markAllAsRead() {
|
async function markAllAsRead() {
|
||||||
@@ -167,7 +162,7 @@ items-center px-2 w-max top-6 lg:top-22"
|
|||||||
<div
|
<div
|
||||||
class="flex flex-col list-none flex-1 h-full divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
|
class="flex flex-col list-none flex-1 h-full divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
|
||||||
>
|
>
|
||||||
{#if !inbox || (inbox?.length ?? 0) == 0}
|
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={Inbox}
|
icon={Inbox}
|
||||||
title={$t('routes.inbox.empty.title')}
|
title={$t('routes.inbox.empty.title')}
|
||||||
@@ -175,7 +170,7 @@ items-center px-2 w-max top-6 lg:top-22"
|
|||||||
class="self-center justify-self-center my-auto"
|
class="self-center justify-self-center my-auto"
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
{#each inbox as item, index (item.id)}
|
{#each data.inbox.value as item, index (item.id)}
|
||||||
<div
|
<div
|
||||||
class="-mx-4 sm:-mx-6 px-4 sm:px-6
|
class="-mx-4 sm:-mx-6 px-4 sm:px-6
|
||||||
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
|
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
|
||||||
@@ -187,17 +182,19 @@ items-center px-2 w-max top-6 lg:top-22"
|
|||||||
delay: index * 50,
|
delay: index * 50,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<InboxItem bind:item={inbox[index]} />
|
<InboxItem bind:item={data.inbox.value[index]} />
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
{#if !(data.page == 1 && (data?.data?.length ?? 0) == 0)}
|
{#if !(data.page == 1 && (data?.inbox?.value.length ?? 0) == 0)}
|
||||||
<div
|
<div
|
||||||
class="sticky z-30 mx-auto max-w-full self-end mt-auto bottom-22 lg:bottom-6"
|
class="sticky z-30 mx-auto max-w-full self-end mt-auto bottom-22 lg:bottom-6"
|
||||||
>
|
>
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Tabs routes={[]} class="mx-auto">
|
||||||
<Pageination
|
<Pageination
|
||||||
hasMore={!(!inbox || (inbox?.length ?? 0) < (data?.limit ?? 0))}
|
hasMore={!(
|
||||||
|
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
|
||||||
|
)}
|
||||||
page={data.page}
|
page={data.page}
|
||||||
href={(page) => `?page=${page}`}
|
href={(page) => `?page=${page}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
generalizePersonMention,
|
generalizePersonMention,
|
||||||
generalizePrivateMessage,
|
generalizePrivateMessage,
|
||||||
} from '$lib/lemmy/inbox.js'
|
} from '$lib/lemmy/inbox.js'
|
||||||
|
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
|
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
|
||||||
@@ -61,7 +62,7 @@ export async function load({ url, fetch }) {
|
|||||||
unreadOnly: unreadOnly,
|
unreadOnly: unreadOnly,
|
||||||
type: type,
|
type: type,
|
||||||
page: page,
|
page: page,
|
||||||
data: data,
|
inbox: new ReactiveState(data),
|
||||||
limit: 20,
|
limit: 20,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { client } from '$lib/lemmy.svelte.js'
|
import { client } from '$lib/lemmy.svelte.js'
|
||||||
import { awaitIfServer } from '$lib/promise.js'
|
import { awaitIfServer } from '$lib/promise.svelte.js'
|
||||||
|
|
||||||
export async function load({ fetch, url }) {
|
export async function load({ fetch, url }) {
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { client } from '$lib/lemmy.svelte.js'
|
import { client } from '$lib/lemmy.svelte.js'
|
||||||
import { awaitIfServer } from '$lib/promise.js'
|
import { awaitIfServer } from '$lib/promise.svelte.js'
|
||||||
|
|
||||||
export async function load({ fetch, params }) {
|
export async function load({ fetch, params }) {
|
||||||
const creator = Number(params.user_id)
|
const creator = Number(params.user_id)
|
||||||
|
|||||||
@@ -54,11 +54,7 @@
|
|||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
import CommentProvider from './CommentProvider.svelte'
|
import CommentProvider from './CommentProvider.svelte'
|
||||||
|
|
||||||
let { data: loaded = $bindable() } = $props()
|
let { data } = $props()
|
||||||
let data = $state(loaded)
|
|
||||||
$effect(() => {
|
|
||||||
data = loaded
|
|
||||||
})
|
|
||||||
|
|
||||||
const updateActions = () => {
|
const updateActions = () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -68,10 +64,10 @@
|
|||||||
name: $t('post.actions.vote.upvote'),
|
name: $t('post.actions.vote.upvote'),
|
||||||
icon: ArrowUp,
|
icon: ArrowUp,
|
||||||
handle: async () => {
|
handle: async () => {
|
||||||
data.post.post_view.my_vote = (
|
data.post.value.post_view.my_vote = (
|
||||||
await client().likePost({
|
await client().likePost({
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.value.post_view.post.id,
|
||||||
score: data.post.post_view.my_vote == 1 ? 0 : 1,
|
score: data.post.value.post_view.my_vote == 1 ? 0 : 1,
|
||||||
})
|
})
|
||||||
).post_view.my_vote
|
).post_view.my_vote
|
||||||
},
|
},
|
||||||
@@ -80,54 +76,54 @@
|
|||||||
name: $t('post.actions.vote.downvote'),
|
name: $t('post.actions.vote.downvote'),
|
||||||
icon: ArrowDown,
|
icon: ArrowDown,
|
||||||
handle: async () => {
|
handle: async () => {
|
||||||
data.post.post_view.my_vote = (
|
data.post.value.post_view.my_vote = (
|
||||||
await client().likePost({
|
await client().likePost({
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.value.post_view.post.id,
|
||||||
score: data.post.post_view.my_vote == -1 ? 0 : -1,
|
score: data.post.value.post_view.my_vote == -1 ? 0 : -1,
|
||||||
})
|
})
|
||||||
).post_view.my_vote
|
).post_view.my_vote
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: data.post.post_view.saved
|
name: data.post.value.post_view.saved
|
||||||
? $t('post.actions.unsave')
|
? $t('post.actions.unsave')
|
||||||
: $t('post.actions.save'),
|
: $t('post.actions.save'),
|
||||||
handle: async () => {
|
handle: async () => {
|
||||||
data.post.post_view.saved = (
|
data.post.value.post_view.saved = (
|
||||||
await client().savePost({
|
await client().savePost({
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.value.post_view.post.id,
|
||||||
save: !data.post.post_view.saved,
|
save: !data.post.value.post_view.saved,
|
||||||
})
|
})
|
||||||
).post_view.saved
|
).post_view.saved
|
||||||
},
|
},
|
||||||
icon: data.post.post_view.saved ? BookmarkSlash : Bookmark,
|
icon: data.post.value.post_view.saved ? BookmarkSlash : Bookmark,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (data.post) updateActions()
|
if (data.post.value) updateActions()
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (
|
if (
|
||||||
!(data.post.post_view.read && settings.markPostsAsRead) &&
|
!(data.post.value.post_view.read && settings.markPostsAsRead) &&
|
||||||
profile.data?.jwt
|
profile.data?.jwt
|
||||||
) {
|
) {
|
||||||
getClient().markPostAsRead({
|
getClient().markPostAsRead({
|
||||||
read: settings.markPostsAsRead,
|
read: settings.markPostsAsRead,
|
||||||
post_ids: [data.post.post_view.post.id],
|
post_ids: [data.post.value.post_view.post.id],
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.value.post_view.post.id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
resumables.add({
|
resumables.add({
|
||||||
name: data.post.post_view.post.name,
|
name: data.post.value.post_view.post.name,
|
||||||
type: 'post',
|
type: 'post',
|
||||||
url: page.url.toString(),
|
url: page.url.toString(),
|
||||||
avatar: data.post.post_view.post.thumbnail_url,
|
avatar: data.post.value.post_view.post.thumbnail_url,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -139,7 +135,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getClient().resolveObject({
|
const res = await getClient().resolveObject({
|
||||||
q: data.post.post_view.post.ap_id,
|
q: data.post.value.post_view.post.ap_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.post) {
|
if (res.post) {
|
||||||
@@ -154,21 +150,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let commentsPage = 1
|
let commentsPage = 1
|
||||||
let commentSort: CommentSortType = $state(data.commentSort)
|
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
async function reloadComments() {
|
async function reloadComments() {
|
||||||
loading = true
|
loading = true
|
||||||
data.comments = getClient().getComments({
|
data.comments.value = getClient().getComments({
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
post_id: data.post.post_view.post.id,
|
post_id: data.post.value.post_view.post.id,
|
||||||
sort: commentSort,
|
sort: data.commentSort.value,
|
||||||
max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3,
|
max_depth: data.post.value.post_view.counts.comments > 100 ? 1 : 3,
|
||||||
})
|
})
|
||||||
loading = false
|
loading = false
|
||||||
data.thread.singleThread = false
|
data.thread.value.singleThread = false
|
||||||
commentsPage = 1
|
commentsPage = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,35 +175,41 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{data.post.post_view.post.name}</title>
|
<title>{data.post.value.post_view.post.name}</title>
|
||||||
<meta property="og:title" content={data.post.post_view.post.name} />
|
<meta property="og:title" content={data.post.value.post_view.post.name} />
|
||||||
<meta property="twitter:title" content={data.post.post_view.post.name} />
|
<meta
|
||||||
|
property="twitter:title"
|
||||||
|
content={data.post.value.post_view.post.name}
|
||||||
|
/>
|
||||||
<meta property="og:url" content={page.url.toString()} />
|
<meta property="og:url" content={page.url.toString()} />
|
||||||
{#if isImage(data.post.post_view.post.url)}
|
{#if isImage(data.post.value.post_view.post.url)}
|
||||||
<meta property="og:image" content={data.post.post_view.post.url} />
|
<meta property="og:image" content={data.post.value.post_view.post.url} />
|
||||||
<meta property="twitter:card" content={data.post.post_view.post.url} />
|
<meta
|
||||||
{:else if data.post.post_view.post.thumbnail_url}
|
property="twitter:card"
|
||||||
|
content={data.post.value.post_view.post.url}
|
||||||
|
/>
|
||||||
|
{:else if data.post.value.post_view.post.thumbnail_url}
|
||||||
<meta
|
<meta
|
||||||
property="og:image"
|
property="og:image"
|
||||||
content={data.post.post_view.post.thumbnail_url}
|
content={data.post.value.post_view.post.thumbnail_url}
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="twitter:card"
|
property="twitter:card"
|
||||||
content={data.post.post_view.post.thumbnail_url}
|
content={data.post.value.post_view.post.thumbnail_url}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if data.post.post_view.post.body}
|
{#if data.post.value.post_view.post.body}
|
||||||
<meta
|
<meta
|
||||||
property="description"
|
property="description"
|
||||||
content={data.post.post_view.post.body.slice(0, 500)}
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="og:description"
|
property="og:description"
|
||||||
content={data.post.post_view.post.body.slice(0, 500)}
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="twitter:description"
|
property="twitter:description"
|
||||||
content={data.post.post_view.post.body.slice(0, 500)}
|
content={data.post.value.post_view.post.body.slice(0, 500)}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
@@ -255,26 +256,26 @@
|
|||||||
<header class="flex flex-col gap-2">
|
<header class="flex flex-col gap-2">
|
||||||
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
<div class="flex flex-row justify-between items-center gap-2 flex-wrap">
|
||||||
<PostMeta
|
<PostMeta
|
||||||
community={data.post.post_view.community}
|
community={data.post.value.post_view.community}
|
||||||
user={data.post.post_view.creator}
|
user={data.post.value.post_view.creator}
|
||||||
bind:subscribed={data.post.community_view.subscribed}
|
bind:subscribed={data.post.value.community_view.subscribed}
|
||||||
badges={{
|
badges={{
|
||||||
deleted: data.post.post_view.post.deleted,
|
deleted: data.post.value.post_view.post.deleted,
|
||||||
removed: data.post.post_view.post.removed,
|
removed: data.post.value.post_view.post.removed,
|
||||||
locked: data.post.post_view.post.locked,
|
locked: data.post.value.post_view.post.locked,
|
||||||
featured:
|
featured:
|
||||||
data.post.post_view.post.featured_community ||
|
data.post.value.post_view.post.featured_community ||
|
||||||
data.post.post_view.post.featured_local,
|
data.post.value.post_view.post.featured_local,
|
||||||
nsfw: data.post.post_view.post.nsfw,
|
nsfw: data.post.value.post_view.post.nsfw,
|
||||||
saved: data.post.post_view.saved,
|
saved: data.post.value.post_view.saved,
|
||||||
admin: data.post.post_view.creator_is_admin,
|
admin: data.post.value.post_view.creator_is_admin,
|
||||||
moderator: data.post.post_view.creator_is_moderator,
|
moderator: data.post.value.post_view.creator_is_moderator,
|
||||||
}}
|
}}
|
||||||
published={publishedToDate(data.post.post_view.post.published)}
|
published={publishedToDate(data.post.value.post_view.post.published)}
|
||||||
edited={data.post.post_view.post.updated}
|
edited={data.post.value.post_view.post.updated}
|
||||||
title={data.post.post_view.post.name}
|
title={data.post.value.post_view.post.name}
|
||||||
style="width: max-content;"
|
style="width: max-content;"
|
||||||
tags={parseTags(data.post.post_view.post.name).tags}
|
tags={parseTags(data.post.value.post_view.post.name).tags}
|
||||||
/>
|
/>
|
||||||
<Button onclick={() => history.back()} size="square-md">
|
<Button onclick={() => history.back()} size="square-md">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -284,26 +285,26 @@
|
|||||||
</div>
|
</div>
|
||||||
<h1 class="font-bold text-xl font-display leading-5">
|
<h1 class="font-bold text-xl font-display leading-5">
|
||||||
<Markdown
|
<Markdown
|
||||||
source={parseTags(data.post.post_view.post.name).title ??
|
source={parseTags(data.post.value.post_view.post.name).title ??
|
||||||
data.post.post_view.post.name}
|
data.post.value.post_view.post.name}
|
||||||
inline
|
inline
|
||||||
/>
|
/>
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
<PostMedia
|
<PostMedia
|
||||||
type={mediaType(data.post.post_view.post.url)}
|
type={mediaType(data.post.value.post_view.post.url)}
|
||||||
post={data.post.post_view.post}
|
post={data.post.value.post_view.post}
|
||||||
opened
|
opened
|
||||||
view="cozy"
|
view="cozy"
|
||||||
/>
|
/>
|
||||||
{#if data.post.post_view.post.body}
|
{#if data.post.value.post_view.post.body}
|
||||||
<div class="text-base text-slate-800 dark:text-zinc-300 leading-[1.5]">
|
<div class="text-base text-slate-800 dark:text-zinc-300 leading-[1.5]">
|
||||||
<Markdown source={data.post.post_view.post.body} />
|
<Markdown source={data.post.value.post_view.post.body} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="w-full relative">
|
<div class="w-full relative">
|
||||||
<PostActions
|
<PostActions
|
||||||
bind:post={data.post.post_view}
|
bind:post={data.post.value.post_view}
|
||||||
onedit={() =>
|
onedit={() =>
|
||||||
toast({
|
toast({
|
||||||
content: 'The post was edited successfully.',
|
content: 'The post was edited successfully.',
|
||||||
@@ -311,16 +312,16 @@
|
|||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{#if data.post.cross_posts?.length > 0}
|
{#if data.post.value.cross_posts?.length > 0}
|
||||||
<Expandable
|
<Expandable
|
||||||
class="text-base mt-2 w-full cursor-pointer"
|
class="text-base mt-2 w-full cursor-pointer"
|
||||||
open={data.post.cross_posts?.length <= 3}
|
open={data.post.value.cross_posts?.length <= 3}
|
||||||
>
|
>
|
||||||
{#snippet title()}
|
{#snippet title()}
|
||||||
<div
|
<div
|
||||||
class="flex items-center gap-1 w-full text-left text-base font-normal"
|
class="flex items-center gap-1 w-full text-left text-base font-normal"
|
||||||
>
|
>
|
||||||
<span class="font-bold">{data.post.cross_posts.length}</span>
|
<span class="font-bold">{data.post.value.cross_posts.length}</span>
|
||||||
{$t('routes.post.crosspostCount')}
|
{$t('routes.post.crosspostCount')}
|
||||||
<hr
|
<hr
|
||||||
class="flex-1 inline-block w-full border-slate-200 dark:border-zinc-800 mx-3"
|
class="flex-1 inline-block w-full border-slate-200 dark:border-zinc-800 mx-3"
|
||||||
@@ -330,14 +331,14 @@
|
|||||||
<div
|
<div
|
||||||
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
|
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
|
||||||
>
|
>
|
||||||
{#each data.post.cross_posts as crosspost}
|
{#each data.post.value.cross_posts as crosspost}
|
||||||
<Post view="compact" actions={false} post={crosspost} />
|
<Post view="compact" actions={false} post={crosspost} />
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
</article>
|
</article>
|
||||||
{#if data.thread.showContext || data.thread.singleThread}
|
{#if data.thread.value.showContext || data.thread.value.singleThread}
|
||||||
<div
|
<div
|
||||||
class="sticky mx-auto z-50 max-w-lg w-full min-w-0 flex items-center overflow-auto gap-1
|
class="sticky mx-auto z-50 max-w-lg w-full min-w-0 flex items-center overflow-auto gap-1
|
||||||
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-200/50 dark:border-zinc-800/50
|
bg-slate-50/50 dark:bg-zinc-900/50 backdrop-blur-xl border border-slate-200/50 dark:border-zinc-800/50
|
||||||
@@ -345,7 +346,7 @@
|
|||||||
>
|
>
|
||||||
<p class="font-medium text-sm flex items-center gap-2">
|
<p class="font-medium text-sm flex items-center gap-2">
|
||||||
<Icon src={InformationCircle} mini size="20" />
|
<Icon src={InformationCircle} mini size="20" />
|
||||||
{data.thread.showContext
|
{data.thread.value.showContext
|
||||||
? $t('routes.post.thread.part')
|
? $t('routes.post.thread.part')
|
||||||
: $t('routes.post.thread.single')}
|
: $t('routes.post.thread.single')}
|
||||||
</p>
|
</p>
|
||||||
@@ -354,13 +355,13 @@
|
|||||||
rounding="pill"
|
rounding="pill"
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
href={data.thread.showContext
|
href={data.thread.value.showContext
|
||||||
? `/comment/${page.params.instance}/${data.thread.showContext}`
|
? `/comment/${page.params.instance}/${data.thread.value.showContext}`
|
||||||
: undefined}
|
: undefined}
|
||||||
class="hover:bg-white/50 dark:hover:bg-zinc-800/30"
|
class="hover:bg-white/50 dark:hover:bg-zinc-800/30"
|
||||||
onclick={data.thread.singleThread ? reloadComments : undefined}
|
onclick={data.thread.value.singleThread ? reloadComments : undefined}
|
||||||
>
|
>
|
||||||
{data.thread.showContext
|
{data.thread.value.showContext
|
||||||
? $t('routes.post.thread.context')
|
? $t('routes.post.thread.context')
|
||||||
: $t('routes.post.thread.allComments')}
|
: $t('routes.post.thread.allComments')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -370,12 +371,12 @@
|
|||||||
<header>
|
<header>
|
||||||
<div class="text-base">
|
<div class="text-base">
|
||||||
<span class="font-bold">
|
<span class="font-bold">
|
||||||
<FormattedNumber number={data.post.post_view.counts.comments} />
|
<FormattedNumber number={data.post.value.post_view.counts.comments} />
|
||||||
</span>
|
</span>
|
||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{#await data.comments}
|
{#await data.comments.value}
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#each new Array(10) as empty, index}
|
{#each new Array(10) as empty, index}
|
||||||
<div
|
<div
|
||||||
@@ -396,11 +397,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{:then comments}
|
{:then comments}
|
||||||
<CommentProvider
|
<CommentProvider
|
||||||
post={data.post}
|
|
||||||
{comments}
|
{comments}
|
||||||
focus={data.thread.focus}
|
post={data.post.value}
|
||||||
|
focus={data.thread.value.focus}
|
||||||
onupdate={reloadComments}
|
onupdate={reloadComments}
|
||||||
bind:sort={commentSort}
|
bind:sort={data.commentSort.value}
|
||||||
/>
|
/>
|
||||||
{#if comments.comments.length == 0}
|
{#if comments.comments.length == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
@@ -410,10 +411,10 @@
|
|||||||
></Placeholder>
|
></Placeholder>
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
{#if data.post.post_view.counts.comments > 5}
|
{#if data.post.value.post_view.counts.comments > 5}
|
||||||
<EndPlaceholder>
|
<EndPlaceholder>
|
||||||
<span class="text-black dark:text-white font-bold">
|
<span class="text-black dark:text-white font-bold">
|
||||||
{data.post.post_view.counts.comments}
|
{data.post.value.post_view.counts.comments}
|
||||||
</span>
|
</span>
|
||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { awaitIfServer } from '$lib/promise.js'
|
import { awaitIfServer } from '$lib/promise.svelte.js'
|
||||||
import { SSR_ENABLED, settings } from '$lib/settings.svelte'
|
import { SSR_ENABLED, settings } from '$lib/settings.svelte'
|
||||||
import type { GetComments } from 'lemmy-js-client'
|
import type { GetComments } from 'lemmy-js-client'
|
||||||
|
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||||
|
|
||||||
export async function load({ params, url, fetch }) {
|
export async function load({ params, url, fetch }) {
|
||||||
const thread = url.searchParams.get('thread')
|
const thread = url.searchParams.get('thread')
|
||||||
@@ -49,14 +50,14 @@ export async function load({ params, url, fetch }) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
thread: {
|
thread: new ReactiveState({
|
||||||
showContext: showContext,
|
showContext: showContext,
|
||||||
singleThread: parentId != undefined,
|
singleThread: parentId != undefined,
|
||||||
focus: thread?.split('.').at(-1),
|
focus: thread?.split('.').at(-1),
|
||||||
},
|
}),
|
||||||
post: post,
|
post: new ReactiveState(post),
|
||||||
commentSort: sort,
|
commentSort: new ReactiveState(sort),
|
||||||
comments: (await awaitIfServer(comments)).data,
|
comments: new ReactiveState((await awaitIfServer(comments)).data),
|
||||||
slots: {
|
slots: {
|
||||||
sidebar: {
|
sidebar: {
|
||||||
component: CommunityCard,
|
component: CommunityCard,
|
||||||
|
|||||||
@@ -46,12 +46,6 @@
|
|||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
let results = $state(data.results)
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
results = data.results
|
|
||||||
})
|
|
||||||
|
|
||||||
let query = $state(data.query || '')
|
let query = $state(data.query || '')
|
||||||
let searchElement: HTMLInputElement | undefined = $state()
|
let searchElement: HTMLInputElement | undefined = $state()
|
||||||
let form = $state<HTMLFormElement>()
|
let form = $state<HTMLFormElement>()
|
||||||
@@ -213,7 +207,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex flex-col mt-4 divide-slate-200 dark:divide-zinc-800 !divide-y"
|
class="flex flex-col mt-4 divide-slate-200 dark:divide-zinc-800 !divide-y"
|
||||||
>
|
>
|
||||||
{#each data.results as result}
|
{#each data.results.value as result}
|
||||||
{#if isPostView(result)}
|
{#if isPostView(result)}
|
||||||
<Post post={result} />
|
<Post post={result} />
|
||||||
{:else if isCommentView(result)}
|
{:else if isCommentView(result)}
|
||||||
@@ -234,7 +228,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4"></div>
|
<div class="mt-4"></div>
|
||||||
{#if data.results.length > 0}
|
{#if data.results.value.length > 0}
|
||||||
<Pageination bind:page={pageNum} href={(page) => `?page=${page}`} />
|
<Pageination bind:page={pageNum} href={(page) => `?page=${page}`} />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { getItemPublished } from '$lib/lemmy/item.js'
|
import { getItemPublished } from '$lib/lemmy/item.js'
|
||||||
|
import { ReactiveState } from '$lib/promise.svelte.js'
|
||||||
import type {
|
import type {
|
||||||
CommentView,
|
CommentView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
@@ -55,7 +56,7 @@ export async function load({ url, fetch }) {
|
|||||||
sort: sort,
|
sort: sort,
|
||||||
page: page,
|
page: page,
|
||||||
query: query,
|
query: query,
|
||||||
results: everything,
|
results: new ReactiveState(everything),
|
||||||
streamed: {
|
streamed: {
|
||||||
object: profile.data?.jwt
|
object: profile.data?.jwt
|
||||||
? getClient(undefined, fetch).resolveObject({
|
? getClient(undefined, fetch).resolveObject({
|
||||||
|
|||||||
Reference in new issue
Block a user