another huge commit but we have notifs now yay

This commit is contained in:
ari melody 2024-07-02 19:38:20 +01:00
parent 015a3e65e1
commit 998e8f2517
Signed by: ari
GPG key ID: CF99829C92678188
17 changed files with 442 additions and 52 deletions

View file

@ -2,7 +2,7 @@ import { client } from '$lib/client/client.js';
import { get, writable } from 'svelte/store';
import { parsePost } from '$lib/client/api.js';
export let posts = writable([]);
export let timeline = writable([]);
let loading = false;
@ -11,8 +11,8 @@ export async function getTimeline(clean) {
loading = true;
let timeline_data;
if (clean || get(posts).length === 0) timeline_data = await get(client).getTimeline()
else timeline_data = await get(client).getTimeline(get(posts)[get(posts).length - 1].id);
if (clean || get(timeline).length === 0) timeline_data = await get(client).getTimeline()
else timeline_data = await get(client).getTimeline(get(timeline)[get(timeline).length - 1].id);
if (!timeline_data) {
console.error(`Failed to retrieve timeline.`);
@ -20,7 +20,7 @@ export async function getTimeline(clean) {
return;
}
if (clean) posts.set([]);
if (clean) timeline.set([]);
for (let i in timeline_data) {
const post_data = timeline_data[i];
@ -36,7 +36,7 @@ export async function getTimeline(clean) {
}
continue;
}
posts.update(current => [...current, post]);
timeline.update(current => [...current, post]);
}
loading = false;
}