diff --git a/src/lib/components/LoadMoreComponent.svelte b/src/lib/components/LoadMoreComponent.svelte index 881c013..691ee6e 100644 --- a/src/lib/components/LoadMoreComponent.svelte +++ b/src/lib/components/LoadMoreComponent.svelte @@ -1,11 +1,40 @@ - - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ac27b3e..0f7bdd0 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,6 +9,8 @@ import LoadMoreComponent from '$lib/components/LoadMoreComponent.svelte'; export let data: PageData; let interval: NodeJS.Timer | null = null; +let moreOlderPostsAvailable = true; +let loadingOlderPosts = false; onMount(async () => { interval = setInterval(async () => { @@ -42,6 +44,7 @@ onMount(async () => { }); async function loadOlderPosts() { + loadingOlderPosts = true; const params = new URLSearchParams(); if (data.posts.length > 0) { params.set('before', data.posts[data.posts.length - 1].created_at); @@ -57,9 +60,14 @@ async function loadOlderPosts() { return arr.map(mapObj => mapObj.url).indexOf(obj.url) === index; }); data.posts = filteredPosts; + moreOlderPostsAvailable = true; + } else { + moreOlderPostsAvailable = false; } + loadingOlderPosts = false; }) .catch(e => { + loadingOlderPosts = false; // TODO: Show error in UI console.error('Error loading older posts', e); }); @@ -80,7 +88,10 @@ async function loadOlderPosts() { {#each data.posts as post (post.url)}
{/each} - +
@@ -88,6 +99,7 @@ async function loadOlderPosts() { .posts { display: flex; flex-direction: column; + align-items: center; } .post { width: 100%;