feat [3/3]: add topic viewing
This commit is contained in:
1 parent
82a8747ad4
commit
a82d8c296d
14 files changed
+422
-319
No files matched your search
@@ -67,7 +67,7 @@
|
|||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
<img
|
<img
|
||||||
src={bestImageURL(post, false, -1, null)}
|
src={blur ? '' : bestImageURL(post, false, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
class={[
|
||||||
'max-w-full rounded-xl z-30 transition-all max-h-[60vh] duration-500 object-contain mx-auto group-hover:scale-98 group-active:scale-95',
|
'max-w-full rounded-xl z-30 transition-all max-h-[60vh] duration-500 object-contain mx-auto group-hover:scale-98 group-active:scale-95',
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
<img
|
<img
|
||||||
src={bestImageURL(post, thumbnail, -1, null)}
|
src={blur ? '' : bestImageURL(post, thumbnail, -1, null)}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class={[
|
class={[
|
||||||
'object-cover relative overflow-hidden rounded-xl h-full',
|
'object-cover relative overflow-hidden rounded-xl h-full',
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ export { default as CommonList } from './CommonList.svelte'
|
|||||||
export { default as SearchBar } from './SearchBar.svelte'
|
export { default as SearchBar } from './SearchBar.svelte'
|
||||||
export { default as Shell } from './Shell.svelte'
|
export { default as Shell } from './Shell.svelte'
|
||||||
export { default as Pageination } from './Pageination.svelte'
|
export { default as Pageination } from './Pageination.svelte'
|
||||||
|
export { default as PostListShell } from './pages/PostListShell.svelte'
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { browser } from '$app/environment'
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import type { GetPosts, ListingType, PostView } from '$lib/client/types'
|
||||||
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
|
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
|
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||||
|
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
||||||
|
import { Header } from '$lib/components/ui/layout'
|
||||||
|
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
|
import type { SortType } from 'lemmy-js-client'
|
||||||
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
|
import { ArrowRight, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
posts: PostView[]
|
||||||
|
cursor?: string
|
||||||
|
params: {
|
||||||
|
location?: ListingType
|
||||||
|
sort?: SortType
|
||||||
|
}
|
||||||
|
title?: string
|
||||||
|
extended?: Snippet
|
||||||
|
getParams: GetPosts
|
||||||
|
client: {
|
||||||
|
lastSeen?: number
|
||||||
|
itemHeights?: (number | null)[]
|
||||||
|
}
|
||||||
|
header?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
params,
|
||||||
|
posts = $bindable(),
|
||||||
|
cursor = $bindable(),
|
||||||
|
title,
|
||||||
|
extended: passedExtended,
|
||||||
|
getParams,
|
||||||
|
client = $bindable(),
|
||||||
|
header = true,
|
||||||
|
}: Props = $props()
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (params.sort) settings.defaultSort.sort = params.sort
|
||||||
|
})
|
||||||
|
|
||||||
|
const FeedComponent = $derived(
|
||||||
|
settings.infiniteScroll && browser && !settings.posts.noVirtualize
|
||||||
|
? VirtualFeed
|
||||||
|
: PostFeed,
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2 max-w-full w-full min-w-0">
|
||||||
|
{#if header}
|
||||||
|
<Header pageHeader>
|
||||||
|
{#if title}
|
||||||
|
{title}
|
||||||
|
{/if}
|
||||||
|
{#snippet extended()}
|
||||||
|
{@render passedExtended?.()}
|
||||||
|
<form class="" method="get" action={page.url.pathname}>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
{#if params.location}
|
||||||
|
<Location name="type" navigate bind:selected={params.location} />
|
||||||
|
{/if}
|
||||||
|
{#if params.sort}
|
||||||
|
<Sort
|
||||||
|
placement="bottom"
|
||||||
|
name="sort"
|
||||||
|
navigate
|
||||||
|
bind:selected={params.sort}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
<ViewSelect placement="bottom" />
|
||||||
|
|
||||||
|
<noscript>
|
||||||
|
<Button
|
||||||
|
class="self-end h-[34px] aspect-square"
|
||||||
|
size="custom"
|
||||||
|
submit
|
||||||
|
>
|
||||||
|
<Icon src={ArrowRight} size="16" micro />
|
||||||
|
</Button>
|
||||||
|
</noscript>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/snippet}
|
||||||
|
</Header>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<FeedComponent
|
||||||
|
bind:posts
|
||||||
|
bind:lastSeen={() => client.lastSeen ?? 0, (v) => (client.lastSeen = v)}
|
||||||
|
bind:params={getParams}
|
||||||
|
virtualList={{ itemHeights: client?.itemHeights ?? [] }}
|
||||||
|
/>
|
||||||
|
<svelte:element
|
||||||
|
this={settings.infiniteScroll && !settings.posts.noVirtualize
|
||||||
|
? 'noscript'
|
||||||
|
: 'div'}
|
||||||
|
class="mt-auto flex flex-col"
|
||||||
|
>
|
||||||
|
<Pageination
|
||||||
|
cursor={{ next: cursor }}
|
||||||
|
href={(page) =>
|
||||||
|
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
||||||
|
back={false}
|
||||||
|
/>
|
||||||
|
</svelte:element>
|
||||||
|
</div>
|
||||||
@@ -91,9 +91,10 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/communities"
|
href="/explore/communities"
|
||||||
label={$t('nav.communities')}
|
label={$t('routes.explore.title')}
|
||||||
icon={GlobeAlt}
|
icon={GlobeAlt}
|
||||||
|
isSelectedFilter={(path) => path.startsWith('/explore')}
|
||||||
/>
|
/>
|
||||||
<NavButton href="/search" label={$t('nav.search')} icon={MagnifyingGlass} />
|
<NavButton href="/search" label={$t('nav.search')} icon={MagnifyingGlass} />
|
||||||
<NavButton
|
<NavButton
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import type {
|
|||||||
GetPost,
|
GetPost,
|
||||||
GetPosts,
|
GetPosts,
|
||||||
PostView,
|
PostView,
|
||||||
|
TopicView,
|
||||||
} from '$lib/client/types'
|
} from '$lib/client/types'
|
||||||
import { recursiveEqual } from '$lib/util.svelte'
|
import { recursiveEqual } from '$lib/util.svelte'
|
||||||
import { SvelteMap } from 'svelte/reactivity'
|
import { SvelteMap } from 'svelte/reactivity'
|
||||||
@@ -109,6 +110,19 @@ export interface FeedTypes {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
'/topic/[id]': [
|
||||||
|
GetPosts,
|
||||||
|
{
|
||||||
|
posts: PostView[]
|
||||||
|
next_page?: string
|
||||||
|
params: GetPosts
|
||||||
|
topic: Promise<TopicView | undefined>
|
||||||
|
client: {
|
||||||
|
itemHeights?: (number | null)[]
|
||||||
|
lastSeen?: number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
const feeds = new SvelteMap<keyof FeedTypes, Feed<any, any>>()
|
||||||
|
|||||||
+57
-80
@@ -1,28 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
import { page } from '$app/state'
|
||||||
import { site } from '$lib/client/lemmy.svelte'
|
import { site } from '$lib/client/lemmy.svelte'
|
||||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
|
||||||
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||||
import { Header } from '$lib/components/ui/layout'
|
import { Header, Pageination } from '$lib/components/ui/layout'
|
||||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { settings, SSR_ENABLED } from '$lib/settings.svelte.js'
|
import { settings, SSR_ENABLED } from '$lib/settings.svelte.js'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { ArrowRight, ChartBar, Icon } from 'svelte-hero-icons'
|
import { ArrowRight, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data = $bindable() } = $props()
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (data.filters.value.type_)
|
|
||||||
settings.defaultSort.feed = data.filters.value.type_
|
|
||||||
if (data.filters.value.sort)
|
|
||||||
settings.defaultSort.sort = data.filters.value.sort
|
|
||||||
})
|
|
||||||
|
|
||||||
const FeedComponent = $derived(
|
const FeedComponent = $derived(
|
||||||
settings.infiniteScroll && browser && !settings.posts.noVirtualize
|
settings.infiniteScroll && browser && !settings.posts.noVirtualize
|
||||||
? VirtualFeed
|
? VirtualFeed
|
||||||
@@ -38,43 +30,36 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2 max-w-full w-full min-w-0">
|
<Header pageHeader>
|
||||||
<Header pageHeader>
|
{$t('routes.frontpage.title')}
|
||||||
{$t('routes.frontpage.title')}
|
{#snippet extended()}
|
||||||
|
<form class="" method="get" action={page.url.pathname}>
|
||||||
|
<div class="flex flex-row gap-2">
|
||||||
|
<Location
|
||||||
|
name="type"
|
||||||
|
navigate
|
||||||
|
bind:selected={data.filters.value.type_!}
|
||||||
|
/>
|
||||||
|
<Sort
|
||||||
|
placement="bottom"
|
||||||
|
name="sort"
|
||||||
|
navigate
|
||||||
|
bind:selected={data.filters.value.sort!}
|
||||||
|
/>
|
||||||
|
<ViewSelect placement="bottom" />
|
||||||
|
|
||||||
{#snippet extended()}
|
<noscript>
|
||||||
<form class="" method="get" action="/">
|
<Button class="self-end h-[34px] aspect-square" size="custom" submit>
|
||||||
<div class="flex flex-row gap-2">
|
<Icon src={ArrowRight} size="16" micro />
|
||||||
{#if data.filters.value.type_}
|
</Button>
|
||||||
<Location
|
</noscript>
|
||||||
name="type"
|
</div>
|
||||||
navigate
|
</form>
|
||||||
bind:selected={data.filters.value.type_}
|
{/snippet}
|
||||||
/>
|
</Header>
|
||||||
{/if}
|
|
||||||
<Sort
|
|
||||||
placement="bottom"
|
|
||||||
name="sort"
|
|
||||||
navigate
|
|
||||||
bind:selected={data.filters.value.sort}
|
|
||||||
/>
|
|
||||||
<ViewSelect placement="bottom" />
|
|
||||||
|
|
||||||
<noscript>
|
{#await data.feed.value}
|
||||||
<Button
|
<div class="space-y-4">
|
||||||
class="self-end h-[34px] aspect-square"
|
|
||||||
size="custom"
|
|
||||||
submit
|
|
||||||
>
|
|
||||||
<Icon src={ArrowRight} size="16" micro />
|
|
||||||
</Button>
|
|
||||||
</noscript>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{/snippet}
|
|
||||||
</Header>
|
|
||||||
|
|
||||||
{#await data.feed.value}
|
|
||||||
{#each new Array(5) as _, index}{_}
|
{#each new Array(5) as _, index}{_}
|
||||||
<div
|
<div
|
||||||
class="animate-pop-in"
|
class="animate-pop-in"
|
||||||
@@ -83,37 +68,29 @@
|
|||||||
100}%"
|
100}%"
|
||||||
>
|
>
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
</div>{/each}
|
</div>
|
||||||
{:then feed}
|
{/each}
|
||||||
<FeedComponent
|
</div>
|
||||||
bind:posts={feed.posts}
|
{:then feed}
|
||||||
bind:lastSeen={
|
<FeedComponent
|
||||||
() => feed.client.lastSeen ?? 0, (v) => (feed.client.lastSeen = v)
|
bind:posts={feed.posts}
|
||||||
}
|
bind:lastSeen={
|
||||||
bind:params={feed.params}
|
() => feed.client.lastSeen ?? 0, (v) => (feed.client.lastSeen = v)
|
||||||
virtualList={{ itemHeights: feed.client?.itemHeights ?? [] }}
|
}
|
||||||
|
bind:params={feed.params}
|
||||||
|
virtualList={{ itemHeights: feed.client?.itemHeights ?? [] }}
|
||||||
|
/>
|
||||||
|
<svelte:element
|
||||||
|
this={settings.infiniteScroll && !settings.posts.noVirtualize
|
||||||
|
? 'noscript'
|
||||||
|
: 'div'}
|
||||||
|
class="mt-auto flex flex-col"
|
||||||
|
>
|
||||||
|
<Pageination
|
||||||
|
cursor={{ next: feed.next_page }}
|
||||||
|
href={(page) =>
|
||||||
|
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
||||||
|
back={false}
|
||||||
/>
|
/>
|
||||||
<svelte:element
|
</svelte:element>
|
||||||
this={settings.infiniteScroll && !settings.posts.noVirtualize
|
{/await}
|
||||||
? 'noscript'
|
|
||||||
: 'div'}
|
|
||||||
class="mt-auto flex flex-col"
|
|
||||||
>
|
|
||||||
<EndPlaceholder>
|
|
||||||
<Icon src={ChartBar} size="16" mini />
|
|
||||||
|
|
||||||
{$t('routes.frontpage.footer', {
|
|
||||||
users: site.data?.site_view?.counts?.users_active_day ?? '??',
|
|
||||||
})}
|
|
||||||
{#snippet action()}
|
|
||||||
<Pageination
|
|
||||||
cursor={{ next: feed.next_page }}
|
|
||||||
href={(page) =>
|
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
|
||||||
back={false}
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
</EndPlaceholder>
|
|
||||||
</svelte:element>
|
|
||||||
{/await}
|
|
||||||
</div>
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import { env } from '$env/dynamic/public'
|
|
||||||
import { client } from '$lib/client/lemmy.svelte.js'
|
import { client } from '$lib/client/lemmy.svelte.js'
|
||||||
import type { ListingType, SortType } from '$lib/client/types'
|
import type { ListingType, SortType } from '$lib/client/types'
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
@@ -27,8 +26,6 @@ export async function load({ url, fetch, route }) {
|
|||||||
show_hidden: settings.posts.showHidden,
|
show_hidden: settings.posts.showHidden,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (env.PUBLIC_SSR_ENABLED?.toLowerCase() == 'true') await feedData
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
feed: new ReactiveState((await awaitIfServer(feedData)).data),
|
feed: new ReactiveState((await awaitIfServer(feedData)).data),
|
||||||
filters: new ReactiveState({
|
filters: new ReactiveState({
|
||||||
|
|||||||
@@ -3,26 +3,17 @@
|
|||||||
import { navigating, page } from '$app/state'
|
import { navigating, page } from '$app/state'
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import { site } from '$lib/client/lemmy.svelte'
|
import { site } from '$lib/client/lemmy.svelte'
|
||||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
|
||||||
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
|
import CommunityHeader from '$lib/components/lemmy/community/CommunityHeader.svelte'
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
import { PostListShell } from '$lib/components/ui/layout'
|
||||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
|
||||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
|
||||||
import { Header } from '$lib/components/ui/layout'
|
|
||||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { resumables } from '$lib/lemmy/item'
|
import { resumables } from '$lib/lemmy/item'
|
||||||
import { setSessionStorage } from '$lib/session.js'
|
import { setSessionStorage } from '$lib/session.js'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { Badge, Button, Note } from 'mono-svelte'
|
||||||
import { Badge, Button, Modal, Note } from 'mono-svelte'
|
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
import { ArrowRight, ChartBar, Icon, Plus, XMark } from 'svelte-hero-icons'
|
import { ArrowRight, Icon, Plus } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
let sidebar: boolean = $state(false)
|
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (browser)
|
if (browser)
|
||||||
setSessionStorage(
|
setSessionStorage(
|
||||||
@@ -62,22 +53,16 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
{#if sidebar}
|
<PostListShell
|
||||||
<Modal bind:open={sidebar}>
|
posts={data.posts}
|
||||||
{#snippet customTitle()}
|
cursor={data.next_page}
|
||||||
<span>About</span>
|
getParams={data.params}
|
||||||
{/snippet}
|
params={{
|
||||||
<div>
|
sort: data.params.sort!,
|
||||||
<CommunityCard
|
}}
|
||||||
bind:community_view={data.community.community_view}
|
client={data.client}
|
||||||
moderators={data.community.moderators}
|
>
|
||||||
/>
|
{#snippet extended()}
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Header pageHeader>
|
|
||||||
<div class="flex flex-col w-full">
|
|
||||||
<CommunityHeader
|
<CommunityHeader
|
||||||
bind:community={data.community.community_view.community}
|
bind:community={data.community.community_view.community}
|
||||||
bind:subscribed={data.community.community_view.subscribed}
|
bind:subscribed={data.community.community_view.subscribed}
|
||||||
@@ -88,93 +73,43 @@
|
|||||||
compact="lg"
|
compact="lg"
|
||||||
avatarCircle={false}
|
avatarCircle={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
{#if data.community.community_view.blocked}
|
||||||
{#snippet extended()}
|
<Note>You've blocked this community.</Note>
|
||||||
<div class="flex flex-row gap-2">
|
{/if}
|
||||||
<Sort selected={data.params.sort!} />
|
{#if profile.current.user}
|
||||||
<ViewSelect showLabel />
|
{#if !data.community.discussion_languages.every( (l) => profile.current.user?.discussion_languages.includes(l), ) && profile.current.user.discussion_languages.length > 0}
|
||||||
</div>
|
{@const missing = data.community.discussion_languages.filter(
|
||||||
{/snippet}
|
(i) => !profile.current.user?.discussion_languages.includes(i),
|
||||||
</Header>
|
)}
|
||||||
|
<Note class="p-1! pl-3! flex-col md:flex-row">
|
||||||
{#if profile.current.user}
|
<div>{$t('routes.community.languageWarning')}</div>
|
||||||
{#if !data.community.discussion_languages.every( (l) => profile.current.user?.discussion_languages.includes(l), ) && profile.current.user.discussion_languages.length > 0}
|
<Button
|
||||||
{@const missing = data.community.discussion_languages.filter(
|
class="inline-block ml-auto"
|
||||||
(i) => !profile.current.user?.discussion_languages.includes(i),
|
href="/profile/settings"
|
||||||
)}
|
color="tertiary"
|
||||||
<Note class="p-1! pl-3! flex-col md:flex-row">
|
rounding="pill"
|
||||||
<div>{$t('routes.community.languageWarning')}</div>
|
size="md"
|
||||||
<Button
|
>
|
||||||
class="inline-block ml-auto"
|
{$t('profile.profile')}
|
||||||
href="/profile/settings"
|
{#snippet suffix()}
|
||||||
color="tertiary"
|
<Icon src={ArrowRight} size="16" micro />
|
||||||
rounding="pill"
|
{/snippet}
|
||||||
size="md"
|
</Button>
|
||||||
>
|
</Note>
|
||||||
{$t('profile.profile')}
|
<div class="flex flex-row gap-4 flex-wrap -mt-2">
|
||||||
{#snippet suffix()}
|
{#if site.data?.all_languages}
|
||||||
<Icon src={ArrowRight} size="16" micro />
|
{@const allLanguages = site.data.all_languages}
|
||||||
{/snippet}
|
{#each missing as language (language)}
|
||||||
</Button>
|
<a href="/profile/settings#languages" class="inline-block w-max">
|
||||||
</Note>
|
<Badge color="blue-subtle">
|
||||||
<div class="flex flex-row gap-4 flex-wrap -mt-2">
|
<Icon src={Plus} size="16" micro />
|
||||||
{#if site.data?.all_languages}
|
{allLanguages.find((i) => language == i.id)?.name}
|
||||||
{@const allLanguages = site.data.all_languages}
|
</Badge>
|
||||||
{#each missing as language (language)}
|
</a>
|
||||||
<a href="/profile/settings#languages" class="inline-block w-max">
|
{/each}
|
||||||
<Badge color="blue-subtle">
|
{/if}
|
||||||
<Icon src={Plus} size="16" micro />
|
</div>
|
||||||
{allLanguages.find((i) => language == i.id)?.name}
|
|
||||||
</Badge>
|
|
||||||
</a>
|
|
||||||
{/each}
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
{/snippet}
|
||||||
{/if}
|
</PostListShell>
|
||||||
|
|
||||||
{#if data.community.community_view.blocked}
|
|
||||||
<Placeholder
|
|
||||||
icon={XMark}
|
|
||||||
title="Blocked"
|
|
||||||
description="You've blocked this community."
|
|
||||||
>
|
|
||||||
<Button href="/profile/blocks">
|
|
||||||
{#snippet suffix()}
|
|
||||||
<Icon src={ArrowRight} size="16" mini />
|
|
||||||
{/snippet}
|
|
||||||
Blocked Communities
|
|
||||||
</Button>
|
|
||||||
</Placeholder>
|
|
||||||
{:else}
|
|
||||||
{@const SvelteComponent = browser ? VirtualFeed : PostFeed}
|
|
||||||
<SvelteComponent
|
|
||||||
bind:posts={data.posts}
|
|
||||||
bind:lastSeen={
|
|
||||||
() => data.client.lastSeen ?? 0, (v) => (data.client.lastSeen = v)
|
|
||||||
}
|
|
||||||
bind:params={data.params}
|
|
||||||
virtualList={{ itemHeights: data.client?.itemHeights ?? [] }}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<svelte:element
|
|
||||||
this={settings.infiniteScroll ? 'noscript' : 'div'}
|
|
||||||
class="mt-auto"
|
|
||||||
>
|
|
||||||
<Pageination
|
|
||||||
cursor={{ next: data.next_page }}
|
|
||||||
href={(page) =>
|
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
|
||||||
>
|
|
||||||
<span class="flex flex-row items-center gap-1">
|
|
||||||
<Icon src={ChartBar} size="16" mini />
|
|
||||||
{$t('routes.frontpage.footer', {
|
|
||||||
users: site.data?.site_view.counts.users_active_day ?? '??',
|
|
||||||
})}
|
|
||||||
</span>
|
|
||||||
</Pageination>
|
|
||||||
</svelte:element>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
</style>
|
|
||||||
@@ -9,4 +9,4 @@
|
|||||||
let { topic }: Props = $props()
|
let { topic }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<CommonItem title={topic.title ?? topic.name} href="/t/{topic.id}" />
|
<CommonItem title={topic.title ?? topic.name} href="/topic/{topic.id}" />
|
||||||
+48
-104
@@ -1,21 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
|
||||||
import { page } from '$app/state'
|
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
|
||||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
|
||||||
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||||
import { PostFeed, VirtualFeed } from '$lib/components/lemmy/post'
|
|
||||||
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import { Header } from '$lib/components/ui/layout'
|
import { PostListShell } from '$lib/components/ui/layout'
|
||||||
import Pageination from '$lib/components/ui/layout/Pageination.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import type { FeedTypes } from '$lib/lemmy/feeds/feed.svelte.js'
|
import type { FeedTypes } from '$lib/lemmy/feeds/feed.svelte.js'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import { communityLink } from '$lib/util.svelte.js'
|
import { communityLink } from '$lib/util.svelte.js'
|
||||||
import { Spinner } from 'mono-svelte'
|
import { Spinner } from 'mono-svelte'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
|
||||||
import { ArrowRight, Icon } from 'svelte-hero-icons'
|
|
||||||
import { SvelteURL } from 'svelte/reactivity'
|
import { SvelteURL } from 'svelte/reactivity'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -24,16 +15,6 @@
|
|||||||
|
|
||||||
let { data = $bindable() }: Props = $props()
|
let { data = $bindable() }: Props = $props()
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (data.params.sort) settings.defaultSort.sort = data.params.sort
|
|
||||||
})
|
|
||||||
|
|
||||||
const FeedComponent = $derived(
|
|
||||||
settings.infiniteScroll && browser && !settings.posts.noVirtualize
|
|
||||||
? VirtualFeed
|
|
||||||
: PostFeed,
|
|
||||||
)
|
|
||||||
|
|
||||||
let title = $state('Loading...')
|
let title = $state('Loading...')
|
||||||
data.feed.then((i) => (title = i?.title ?? ''))
|
data.feed.then((i) => (title = i?.title ?? ''))
|
||||||
</script>
|
</script>
|
||||||
@@ -44,87 +25,50 @@
|
|||||||
</title>
|
</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2 max-w-full w-full min-w-0">
|
<PostListShell
|
||||||
<Header pageHeader>
|
client={data.client}
|
||||||
{#snippet extended()}
|
posts={data.posts}
|
||||||
<div class="min-h-56 grid place-items-center">
|
cursor={data.next_page}
|
||||||
{#await data.feed}
|
getParams={data.params}
|
||||||
<Spinner width={32} />
|
params={{
|
||||||
{:then feed}
|
sort: data.params.sort!,
|
||||||
{#if feed}
|
}}
|
||||||
<EntityHeader
|
>
|
||||||
class="w-full relative flex flex-col"
|
{#snippet extended()}
|
||||||
compact="always"
|
<div class="min-h-56 grid place-items-center">
|
||||||
avatarCircle={false}
|
{#await data.feed}
|
||||||
name={feed.title}
|
<Spinner width={32} />
|
||||||
avatar={feed.icon}
|
{:then feed}
|
||||||
>
|
{#if feed}
|
||||||
{#snippet nameDetail()}
|
<EntityHeader
|
||||||
<p class="text-lg">{feed.name}</p>
|
class="w-full relative flex flex-col"
|
||||||
{/snippet}
|
compact="always"
|
||||||
{#if feed.communities}
|
avatarCircle={false}
|
||||||
<Expandable>
|
name={feed.title}
|
||||||
{#snippet title()}
|
avatar={feed.icon}
|
||||||
{$t('content.communities')}
|
>
|
||||||
{/snippet}
|
{#snippet nameDetail()}
|
||||||
<ItemList
|
<p class="text-lg">{feed.name}</p>
|
||||||
items={feed.communities.map((i) => ({
|
{/snippet}
|
||||||
id: i.id,
|
{#if feed.communities}
|
||||||
name: i.title,
|
<Expandable>
|
||||||
url: communityLink(i),
|
{#snippet title()}
|
||||||
avatar: i.icon,
|
{$t('content.communities')}
|
||||||
instance: new SvelteURL(i.actor_id).hostname,
|
{/snippet}
|
||||||
}))}
|
<ItemList
|
||||||
/>
|
items={feed.communities.map((i) => ({
|
||||||
</Expandable>
|
id: i.id,
|
||||||
{/if}
|
name: i.title,
|
||||||
</EntityHeader>
|
url: communityLink(i),
|
||||||
{/if}
|
avatar: i.icon,
|
||||||
{/await}
|
instance: new SvelteURL(i.actor_id).hostname,
|
||||||
</div>
|
}))}
|
||||||
<form class="" method="get" action={page.url.pathname}>
|
/>
|
||||||
<div class="flex flex-row gap-2">
|
</Expandable>
|
||||||
<Sort
|
{/if}
|
||||||
placement="bottom"
|
</EntityHeader>
|
||||||
name="sort"
|
{/if}
|
||||||
navigate
|
{/await}
|
||||||
bind:selected={data.params.sort!}
|
</div>
|
||||||
/>
|
{/snippet}
|
||||||
<ViewSelect placement="bottom" />
|
</PostListShell>
|
||||||
|
|
||||||
<noscript>
|
|
||||||
<Button
|
|
||||||
class="self-end h-[34px] aspect-square"
|
|
||||||
size="custom"
|
|
||||||
submit
|
|
||||||
>
|
|
||||||
<Icon src={ArrowRight} size="16" micro />
|
|
||||||
</Button>
|
|
||||||
</noscript>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
{/snippet}
|
|
||||||
</Header>
|
|
||||||
|
|
||||||
<FeedComponent
|
|
||||||
bind:posts={data.posts}
|
|
||||||
bind:lastSeen={
|
|
||||||
() => data.client.lastSeen ?? 0, (v) => (data.client.lastSeen = v)
|
|
||||||
}
|
|
||||||
bind:params={data.params}
|
|
||||||
virtualList={{ itemHeights: data.client?.itemHeights ?? [] }}
|
|
||||||
/>
|
|
||||||
<svelte:element
|
|
||||||
this={settings.infiniteScroll && !settings.posts.noVirtualize
|
|
||||||
? 'noscript'
|
|
||||||
: 'div'}
|
|
||||||
class="mt-auto flex flex-col"
|
|
||||||
>
|
|
||||||
<Pageination
|
|
||||||
cursor={{ next: data.next_page }}
|
|
||||||
href={(page) =>
|
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
|
||||||
back={false}
|
|
||||||
/>
|
|
||||||
</svelte:element>
|
|
||||||
</div>
|
|
||||||
@@ -25,15 +25,28 @@ function buildContext(thread?: string) {
|
|||||||
return { parentId, showContext, max_depth, focus: thread?.split('.').at(-1) }
|
return { parentId, showContext, max_depth, focus: thread?.split('.').at(-1) }
|
||||||
}
|
}
|
||||||
|
|
||||||
function findInFeed(id: '/' | '/c/[name]', postId: string) {
|
async function findInFeed(id: '/' | '/c/[name]' | '/f/[id]', postId: string) {
|
||||||
return feed(id, async (p) => ({
|
// this never actually loads anything
|
||||||
// this will never run
|
if (id == '/') {
|
||||||
...(await client().getPosts(p)),
|
const resolved = feed(id, async (p) => ({
|
||||||
client: {},
|
posts: (await client().getPosts(p)).posts,
|
||||||
params: p,
|
client: {},
|
||||||
}))
|
params: p,
|
||||||
.peek()
|
})).peek()
|
||||||
?.posts.find((i) => i.post.id.toString() == postId)
|
|
||||||
|
return resolved
|
||||||
|
? resolved?.posts?.find((i) => i.post.id.toString() == postId)
|
||||||
|
: undefined
|
||||||
|
} else {
|
||||||
|
return feed(id, async (p) => ({
|
||||||
|
...(await client().getPosts(p)),
|
||||||
|
client: {},
|
||||||
|
params: p,
|
||||||
|
community: await client().getCommunity({}),
|
||||||
|
}))
|
||||||
|
.peek()
|
||||||
|
?.posts.find((i) => i.post.id.toString() == postId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function load({ params, url, route }) {
|
export async function load({ params, url, route }) {
|
||||||
@@ -44,7 +57,9 @@ export async function load({ params, url, route }) {
|
|||||||
const sort = settings?.defaultSort?.comments ?? 'Hot'
|
const sort = settings?.defaultSort?.comments ?? 'Hot'
|
||||||
|
|
||||||
const cachedPost =
|
const cachedPost =
|
||||||
findInFeed('/', params.id) ?? findInFeed('/c/[name]', params.id)
|
(await findInFeed('/', params.id)) ??
|
||||||
|
(await findInFeed('/c/[name]', params.id)) ??
|
||||||
|
(await findInFeed('/f/[id]', params.id))
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parentId,
|
parentId,
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
|
||||||
|
import EntityHeader from '$lib/components/ui/EntityHeader.svelte'
|
||||||
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
import { PostListShell } from '$lib/components/ui/layout'
|
||||||
|
import { t } from '$lib/i18n/translations.js'
|
||||||
|
import { communityLink } from '$lib/util.svelte.js'
|
||||||
|
import { Spinner } from 'mono-svelte'
|
||||||
|
import { SvelteURL } from 'svelte/reactivity'
|
||||||
|
|
||||||
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
|
let title = $state('Loading...')
|
||||||
|
data.topic.then((i) => (title = i?.title ?? ''))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>
|
||||||
|
{title}
|
||||||
|
</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<PostListShell
|
||||||
|
client={data.client}
|
||||||
|
posts={data.posts}
|
||||||
|
cursor={data.next_page}
|
||||||
|
getParams={data.params}
|
||||||
|
params={{
|
||||||
|
sort: data.params.sort!,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#snippet extended()}
|
||||||
|
<div class="min-h-56 grid place-items-center">
|
||||||
|
{#await data.topic}
|
||||||
|
<Spinner width={32} />
|
||||||
|
{:then topic}
|
||||||
|
{#if topic}
|
||||||
|
<EntityHeader
|
||||||
|
class="w-full relative flex flex-col"
|
||||||
|
compact="always"
|
||||||
|
avatarCircle={false}
|
||||||
|
name={topic.name}
|
||||||
|
>
|
||||||
|
{#snippet nameDetail()}
|
||||||
|
<p class="text-lg">{topic.name}</p>
|
||||||
|
{/snippet}
|
||||||
|
{#if topic.communities}
|
||||||
|
<Expandable>
|
||||||
|
{#snippet title()}
|
||||||
|
{$t('content.communities')}
|
||||||
|
{/snippet}
|
||||||
|
<ItemList
|
||||||
|
items={topic.communities.map((i) => ({
|
||||||
|
id: i.id,
|
||||||
|
name: i.title,
|
||||||
|
url: communityLink(i),
|
||||||
|
avatar: i.icon,
|
||||||
|
instance: new SvelteURL(i.actor_id).hostname,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Expandable>
|
||||||
|
{/if}
|
||||||
|
</EntityHeader>
|
||||||
|
{/if}
|
||||||
|
{/await}
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
</PostListShell>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { client } from '$lib/client/lemmy.svelte.js'
|
||||||
|
import type { SortType } from '$lib/client/types'
|
||||||
|
import { feed } from '$lib/lemmy/feeds/feed.svelte.js'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
|
import { error } from '@sveltejs/kit'
|
||||||
|
|
||||||
|
export async function load({ url, fetch, route, params }) {
|
||||||
|
const piefed = client({ func: fetch })
|
||||||
|
|
||||||
|
if (!piefed.getTopics) error(404, 'unsupported')
|
||||||
|
|
||||||
|
const sort: SortType =
|
||||||
|
(url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
|
||||||
|
|
||||||
|
const cursor = url.searchParams.get('cursor') as string | undefined
|
||||||
|
|
||||||
|
const feedData = await feed(route.id, async (p) => {
|
||||||
|
const piefedTopicData = piefed.getTopics!({
|
||||||
|
include_communities: true,
|
||||||
|
}).then((i) => i.topics.find((j) => j.id.toString() == p.topic_id!))
|
||||||
|
|
||||||
|
return {
|
||||||
|
...(await piefed.getPosts(p)),
|
||||||
|
topic: piefedTopicData,
|
||||||
|
params: p,
|
||||||
|
client: {},
|
||||||
|
}
|
||||||
|
}).load({
|
||||||
|
page_cursor: cursor,
|
||||||
|
sort: sort,
|
||||||
|
type_: 'All',
|
||||||
|
limit: 20,
|
||||||
|
show_hidden: settings.posts.showHidden,
|
||||||
|
topic_id: params.id,
|
||||||
|
})
|
||||||
|
|
||||||
|
return feedData
|
||||||
|
}
|
||||||
Reference in new issue
Block a user