diff --git a/src/lib/components/layout/main/DynamicLinks.svelte b/src/lib/components/layout/main/DynamicLinks.svelte index dfe1e47..b843145 100644 --- a/src/lib/components/layout/main/DynamicLinks.svelte +++ b/src/lib/components/layout/main/DynamicLinks.svelte @@ -1,6 +1,8 @@ {#if isVisible}
- {#if data && data.cards.length > 0} + {#if displayData && displayData.cards.length > 0} - {:else if data !== undefined} + {:else if displayData !== undefined}
create a blue.linkat.board record at https://linkat.blue/ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ee672c1..8f51656 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,6 +2,7 @@ import { onMount } from "svelte"; import { getStores } from "$app/stores"; import { createComponentDebugger } from "$lib/utils/debug.js"; + import { getCache } from "$utils/cache"; import type { Post, LinkBoard } from "$components/shared"; const { page } = getStores(); @@ -24,6 +25,9 @@ let isLoadingPosts = $state(false); let isLoadingLinks = $state(false); + // Check if we have cached data for links + let hasCachedLinks = $state(false); + onMount(() => { debug.lifecycle('MainPage', 'mounted', { hasData: !!data, @@ -32,6 +36,13 @@ initialDynamicLinksCount: data?.dynamicLinks ? 'hasData' : 'noData' }); + // Check for cached links data immediately + const cachedLinks = getCache('dynamic_links_data'); + if (cachedLinks && cachedLinks.cards && cachedLinks.cards.length > 0) { + hasCachedLinks = true; + debug.debug('Found cached links data'); + } + // Set a brief timeout to ensure the browser has time to determine locale setTimeout(() => { localeLoaded = true; @@ -76,8 +87,8 @@ }, 2500); // Wait 2.5 seconds before loading posts } - // Phase 3: Load dynamic links if not already loaded (with longer delay) - if (!dynamicLinksLoaded && data?.profile?.pds && data?.profile?.did) { + // Phase 3: Load dynamic links if not already loaded and no cached data + if (!dynamicLinksLoaded && !hasCachedLinks && data?.profile?.pds && data?.profile?.did) { setTimeout(async () => { try { isLoadingLinks = true; @@ -100,8 +111,8 @@ isLoadingLinks = false; } }, 5000); // Wait 5 seconds before loading links - } else if (!data?.profile?.pds || !data?.profile?.did) { - // If we don't have the necessary profile data, mark as loaded to prevent loading state + } else if (!data?.profile?.pds || !data?.profile?.did || hasCachedLinks) { + // If we don't have the necessary profile data or we have cached data, mark as loaded dynamicLinksLoaded = true; } @@ -118,6 +129,7 @@ dynamicLinksType: typeof dynamicLinksData, hasLatestPosts: !!latestPosts?.length, hasDynamicLinks: !!dynamicLinksData, + hasCachedLinks, blogPostsLoaded, dynamicLinksLoaded }); @@ -173,10 +185,11 @@
{/if} - -{#if dynamicLinksLoaded} - -{:else if isLoadingLinks} + + + + +{#if !hasCachedLinks && isLoadingLinks && !dynamicLinksLoaded}
Loading links...