feat: ssr comments if env var is enabled
This commit is contained in:
1 parent
c030196c35
commit
2c4132d899
2 files changed
+19
-12
No files matched your search
@@ -5,6 +5,8 @@ import { env } from '$env/dynamic/public'
|
|||||||
console.log('Using the following default settings from the environment:')
|
console.log('Using the following default settings from the environment:')
|
||||||
console.log(env)
|
console.log(env)
|
||||||
|
|
||||||
|
export const SSR_ENABLED = env.PUBLIC_SSR_ENABLED.toLowerCase() == 'true'
|
||||||
|
|
||||||
// Returns a proper boolean or null. Used to set boolean values from env var strings while allowing nullish coalescing to set default values.
|
// Returns a proper boolean or null. Used to set boolean values from env var strings while allowing nullish coalescing to set default values.
|
||||||
const toBool = (str: string | undefined) => {
|
const toBool = (str: string | undefined) => {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import { env } from '$env/dynamic/public'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { SSR_ENABLED, userSettings } from '$lib/settings.js'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
@@ -29,22 +30,26 @@ export async function load({ params, url, fetch }) {
|
|||||||
|
|
||||||
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
|
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
|
||||||
|
|
||||||
|
const commentParams: any = {
|
||||||
|
post_id: Number(params.id),
|
||||||
|
type_: 'All',
|
||||||
|
limit: 50,
|
||||||
|
page: 1,
|
||||||
|
max_depth: max_depth,
|
||||||
|
saved_only: false,
|
||||||
|
sort: sort,
|
||||||
|
auth: get(profile)?.jwt,
|
||||||
|
parent_id: parentId,
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
singleThread: parentId != undefined,
|
singleThread: parentId != undefined,
|
||||||
post: post,
|
post: post,
|
||||||
commentSort: sort,
|
commentSort: sort,
|
||||||
streamed: {
|
streamed: {
|
||||||
comments: getClient(params.instance.toLowerCase(), fetch).getComments({
|
comments: SSR_ENABLED
|
||||||
post_id: Number(params.id),
|
? await getClient(params.instance, fetch).getComments(commentParams)
|
||||||
type_: 'All',
|
: getClient(params.instance, fetch).getComments(commentParams),
|
||||||
limit: 50,
|
|
||||||
page: 1,
|
|
||||||
max_depth: max_depth,
|
|
||||||
saved_only: false,
|
|
||||||
sort: sort,
|
|
||||||
auth: get(profile)?.jwt,
|
|
||||||
parent_id: parentId,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user