diff --git a/packages/experiments/src/lib/db/feed.ts b/packages/experiments/src/lib/db/feed.ts index f5b252e07..75154d95e 100644 --- a/packages/experiments/src/lib/db/feed.ts +++ b/packages/experiments/src/lib/db/feed.ts @@ -21,7 +21,10 @@ import type { IDBStores } from '$lib/idb/idb' import { get } from 'svelte/store' import { authState } from '$stores/auth' -export async function getVideos(lastRef?: QueryDocumentSnapshot) { +export async function getVideos( + lastRef?: QueryDocumentSnapshot, + keepId?: string, +) { try { const videos: UpDownPost[] = [] const db = getDb() @@ -51,7 +54,7 @@ export async function getVideos(lastRef?: QueryDocumentSnapshot) { ) snapshot.forEach((doc) => { - if (!alreadyWatchedPosts.includes(doc.id)) { + if (!alreadyWatchedPosts.includes(doc.id) || doc.id === keepId) { videos.push({ ...doc.data(), id: doc.id } as UpDownPost) } }) diff --git a/packages/experiments/src/routes/(feed)/up-down/[id]/+page.svelte b/packages/experiments/src/routes/(feed)/up-down/[id]/+page.svelte index 35392d6a9..7434f3f07 100644 --- a/packages/experiments/src/routes/(feed)/up-down/[id]/+page.svelte +++ b/packages/experiments/src/routes/(feed)/up-down/[id]/+page.svelte @@ -16,6 +16,7 @@ import type { QueryDocumentSnapshot } from 'firebase/firestore' import PlayerRenderer from '$components/layout/PlayerRenderer.svelte' import { debounce } from 'throttle-debounce' import { removeSplashScreen } from '$stores/popups' +import { page } from '$app/stores' const fetchWhenVideosLeft = 5 const keepVideosLoadedCount: number = 4 @@ -24,6 +25,7 @@ let videos: UpDownPost[] = [] let currentVideoIndex = 0 let noMoreVideos = false let loading = false +let first = true let lastLoadedVideoRef: QueryDocumentSnapshot | undefined = undefined let showError = false @@ -43,7 +45,10 @@ async function fetchNextVideos() { loading = true - const res = await getVideos(lastLoadedVideoRef) + const res = await getVideos( + lastLoadedVideoRef, + first ? $page.params.id : undefined, + ) if (!res.ok || !res.videos) { console.log('r2') return