add upvote count, fix loading issues

This commit is contained in:
Yusur 2025-10-07 11:46:05 +02:00
parent 55455c1693
commit cd92a4b12e
4 changed files with 70 additions and 1 deletions

View file

@ -1,7 +1,8 @@
import { backend, type GuildEntry, type PostEntry } from '$lib/backend.js';
import { getMe } from '$lib/globals.svelte.js';
import { getMe, sleep } from '$lib/globals.svelte.js';
import type { LoadEvent } from '@sveltejs/kit';
let isFirstLoad = false;
async function loadFeed (event: LoadEvent): Promise<PostEntry[] | null> {
const resp = await backend.withEvent(event).fetch('home/feed');
@ -40,6 +41,12 @@ async function loadTopGuilds (event: LoadEvent): Promise<GuildEntry[] | null> {
}
export async function load(event): Promise<{feed: PostEntry[] | null, top_guilds?: GuildEntry[] | null}> {
// delay loading after layout
if (!isFirstLoad) {
await sleep(2000);
isFirstLoad = true;
}
let feed = null;
let me = getMe();
let top_guilds = null;