impr: switch to refactored feed handler (#654)

* impr: use refactored feed handler for main & community

* refactor: re-add post preloading to feed handler

* fix: remove unused setting & improve consistency of postmedia compact
This commit is contained in:
xylight authored and GitHub committed 2025-09-12 02:18:32 +00:00
1 parent 2d01124bbf
commit 9460eec7e1
26 files changed
+489 -467

No files matched your search

+18 -18
View File
@@ -1,12 +1,13 @@
import { env } from '$env/dynamic/public'
import { t } from '$lib/i18n/translations.js'
import { postFeed } from '$lib/lemmy/postfeed.svelte.js'
import { ReactiveState, awaitIfServer } from '$lib/util.svelte.js'
import { settings } from '$lib/settings.svelte'
import { client } from '$lib/client/lemmy.svelte.js'
import type { ListingType, SortType } from '$lib/client/types'
import { t } from '$lib/i18n/translations.js'
import { feed } from '$lib/lemmy/feeds/feed.svelte.js'
import { settings } from '$lib/settings.svelte'
import { ReactiveState, awaitIfServer } from '$lib/util.svelte.js'
import { ChevronDoubleUp } from 'svelte-hero-icons'
export async function load({ url, fetch }) {
export async function load({ url, fetch, route }) {
const cursor = url.searchParams.get('cursor') as string | undefined
const sort: SortType =
@@ -14,23 +15,22 @@ export async function load({ url, fetch }) {
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
const feed = postFeed({
id: 'main',
request: {
page_cursor: cursor,
sort: sort,
type_: listingType,
limit: 20,
show_hidden: settings.posts.showHidden,
},
url: url,
fetch: fetch,
const feedData = feed(route.id, async (params) => ({
...(await client({ func: fetch }).getPosts(params)),
params: params,
client: {},
})).load({
page_cursor: cursor,
sort: sort,
type_: listingType,
limit: 20,
show_hidden: settings.posts.showHidden,
})
if (env.PUBLIC_SSR_ENABLED?.toLowerCase() == 'true') await feed
if (env.PUBLIC_SSR_ENABLED?.toLowerCase() == 'true') await feedData
return {
feed: new ReactiveState((await awaitIfServer(feed)).data),
feed: new ReactiveState((await awaitIfServer(feedData)).data),
filters: new ReactiveState({
sort: sort,
type_: listingType,