Minor fixes to feed state manangement

This commit is contained in:
WardPearce
2025-06-01 21:22:18 +12:00
parent 0ff552008c
commit 80cd26aa28
6 changed files with 7 additions and 16 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import VideoList from '$lib/components/VideoList.svelte';
import { feedCacheStore } from '$lib/store.js';
let { data } = $props();
</script>
@@ -11,5 +12,5 @@
<p>Popular page has been disabled</p>
</nav>
{:else}
<VideoList videos={data.popular} />
<VideoList videos={$feedCacheStore.popular ?? []} />
{/if}
-1
View File
@@ -24,7 +24,6 @@ export async function load() {
}
return {
popular: popular,
popularDisabled: popularDisabled
};
}
@@ -6,10 +6,8 @@
import { _ } from 'svelte-i18n';
import InfiniteLoading, { type InfiniteEvent } from 'svelte-infinite-loading';
let { data } = $props();
let currentPage = 1;
let videos: (VideoBase | Video | PlaylistPageVideo)[] = $state(data.videos);
let videos: (VideoBase | Video | PlaylistPageVideo)[] = $state($feedCacheStore.subscription);
async function loadMore(event: InfiniteEvent) {
currentPage++;
@@ -32,6 +30,6 @@
</a>
</nav>
<VideoList {videos} />
<VideoList videos={videos ?? []} />
<InfiniteLoading on:infinite={loadMore} />
@@ -20,11 +20,7 @@ export async function load() {
} else {
await getFeed(100, 1).then((feeds) => {
const newVideos = [...feeds.notifications, ...feeds.videos];
feedCacheStore.set({ subscription: { ...Array.from(new Set(newVideos)), ...videos } });
feedCacheStore.set({ subscription: Array.from(new Set({ ...newVideos, ...videos })) });
});
}
return {
videos: videos
};
}
@@ -1,7 +1,6 @@
<script lang="ts">
import VideoList from '$lib/components/VideoList.svelte';
let { data } = $props();
import { feedCacheStore } from '$lib/store';
</script>
<VideoList videos={data.trending} />
<VideoList videos={$feedCacheStore.trending ?? []} />
@@ -17,6 +17,4 @@ export async function load() {
} else {
getTrending().then((newTrending) => feedCacheStore.set({ trending: newTrending }));
}
return { trending: trending };
}