This commit is contained in:
Xyphyn committed 2023-07-25 11:30:27 -07:00
1 parent 7ea6d141be
commit 90587cfa26
5 files changed
+29 -18

No files matched your search

+4
View File
@@ -8,6 +8,10 @@
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
<h1 class="font-black text-5xl">{$page.status}</h1>
<p>
The <strong>server</strong>
failed to fetch the data. Click "retry" to have the client load it.
</p>
<Button href={$page.url.toString()}>Retry</Button>
<Button
on:click={() => {
+18 -11
View File
@@ -2,6 +2,7 @@ import { authData, getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import type { ListingType, SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
import { error } from '@sveltejs/kit'
export async function load({ url }) {
const page = Number(url.searchParams.get('page') || 1) || 1
@@ -13,16 +14,22 @@ export async function load({ url }) {
(url.searchParams.get('type') as ListingType) ||
get(userSettings).defaultSort.feed
return {
posts: getClient().getPosts({
limit: 20,
page: page,
sort: sort,
type_: listingType,
auth: get(authData)?.token,
}),
streamed: {
site: getClient().getSite({}),
},
try {
return {
posts: await getClient().getPosts({
limit: 20,
page: page,
sort: sort,
type_: listingType,
auth: get(authData)?.token,
}),
streamed: {
site: getClient().getSite({}),
},
}
} catch (err) {
throw error(500, {
message: 'Failed to fetch homepage.',
})
}
}
+2 -2
View File
@@ -11,14 +11,14 @@ export async function load(req: any) {
get(userSettings).defaultSort.sort
return {
posts: getClient().getPosts({
posts: await getClient().getPosts({
limit: 40,
community_name: req.params.name,
page: page,
sort: sort,
auth: get(authData)?.token,
}),
community: getClient().getCommunity({
community: await getClient().getCommunity({
name: req.params.name,
auth: get(authData)?.token,
}),
+3 -3
View File
@@ -2,13 +2,13 @@ import { authData, getClient } from '$lib/lemmy.js'
import type { ListingType } from 'lemmy-js-client'
import { get } from 'svelte/store'
export function load({ url }) {
export async function load({ url }) {
const type = url.searchParams.get('type') as ListingType
const page = Number(url.searchParams.get('page')) || 1
const query = url.searchParams.get('q')
if (query) {
return getClient().search({
return await getClient().search({
limit: 40,
page: page,
sort: 'TopAll',
@@ -18,7 +18,7 @@ export function load({ url }) {
auth: get(authData)?.token,
})
} else {
return getClient().listCommunities({
return await getClient().listCommunities({
limit: 40,
page: page,
sort: 'TopAll',
+2 -2
View File
@@ -1,9 +1,9 @@
import { authData, getClient } from '$lib/lemmy.js'
import { get } from 'svelte/store'
export function load({ params }) {
export async function load({ params }) {
return {
user: getClient().getPersonDetails({
user: await getClient().getPersonDetails({
limit: 40,
page: 1,
username: params.name,