From 9a5018c4e5a8bd40628544c9056e12982b5f1dc7 Mon Sep 17 00:00:00 2001 From: harshbaz Date: Fri, 5 Jan 2024 10:14:15 +0530 Subject: [PATCH] Enable filtering --- packages/experiments/src/routes/loadFirstVideo.ts | 6 +++--- packages/web-client/src/lib/helpers/feed.ts | 12 +++++------- .../routes/(feed)/feed/[id=videoId]/+page.server.ts | 2 +- .../(feed)/hotornot/[id=videoId]/+page.server.ts | 2 +- packages/web-client/tsconfig.json | 1 + 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/experiments/src/routes/loadFirstVideo.ts b/packages/experiments/src/routes/loadFirstVideo.ts index fa4f132a3..1df0fb9e8 100644 --- a/packages/experiments/src/routes/loadFirstVideo.ts +++ b/packages/experiments/src/routes/loadFirstVideo.ts @@ -16,13 +16,13 @@ export const loadFirstVideo: PageLoad = async () => { const q = query(collection(db, 'ud-videos' as CollectionName), limit(1)) const res = await getDocs(q) if (res.empty) { - redirect(307, '/up-down/no-videos'); + redirect(307, '/up-down/no-videos') } const data = res.docs[0].data() as UpDownPost if (data) { - redirect(307, `/up-down/${res.docs[0].id}`); + redirect(307, `/up-down/${res.docs[0].id}`) } else { - redirect(307, '/up-down/no-videos'); + redirect(307, '/up-down/no-videos') } } diff --git a/packages/web-client/src/lib/helpers/feed.ts b/packages/web-client/src/lib/helpers/feed.ts index 813e20a75..c8bad0f46 100644 --- a/packages/web-client/src/lib/helpers/feed.ts +++ b/packages/web-client/src/lib/helpers/feed.ts @@ -185,7 +185,6 @@ export async function getTopPosts( } } -//@ts-ignore async function filterBets( posts: PostScoreIndexItem[], ): Promise { @@ -220,12 +219,11 @@ export async function getHotOrNotPosts( BigInt(from + numberOfPosts), ) if ('Ok' in res) { + const notBetPosts = await filterBets(res.Ok) + const notStuckPosts = await filterStuckCanisterPosts(notBetPosts) + const notReportedPosts = await filterReportedPosts(notStuckPosts) // const notWatchedPosts = await filterPosts(notReportedPosts, 'watch-hon') - - const notStuckPosts = await filterStuckCanisterPosts(res.Ok) - // const notBetPosts = await filterBets(notStuckPosts) - // const notReportedPosts = await filterReportedPosts(notBetPosts) - const populatedRes = await populatePosts(notStuckPosts, false) + const populatedRes = await populatePosts(notReportedPosts, true) if (populatedRes.error) { throw new Error( `Error while populating, ${JSON.stringify(populatedRes)}`, @@ -319,7 +317,7 @@ async function fetchPostDetailById( created_by_profile_photo_url: r.created_by_profile_photo_url[0] || getDefaultImageUrl(r.created_by_user_principal_id, 54), - } as PostPopulated + } satisfies PostPopulated } catch (e) { Log('warn', 'Error while populating post', { error: e, diff --git a/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.server.ts b/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.server.ts index dadaa1a0f..744524ebc 100644 --- a/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.server.ts +++ b/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.server.ts @@ -28,7 +28,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { created_by_user_principal_id: r.created_by_user_principal_id.toText(), post_id: postId, score: BigInt(0), - } as PostPopulated, + } satisfies PostPopulated, } } else { return diff --git a/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.server.ts b/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.server.ts index 77d2f28c2..ffab03e5d 100644 --- a/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.server.ts +++ b/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.server.ts @@ -28,7 +28,7 @@ export const load: PageServerLoad = async ({ params }) => { created_by_user_principal_id: r.created_by_user_principal_id.toText(), post_id: postId, score: BigInt(0), - } as PostPopulated, + } satisfies PostPopulated, } } else { return diff --git a/packages/web-client/tsconfig.json b/packages/web-client/tsconfig.json index f384a2ed8..80cf5da9f 100644 --- a/packages/web-client/tsconfig.json +++ b/packages/web-client/tsconfig.json @@ -8,6 +8,7 @@ "./vite.config.ts", "./src/**/*.js", "./src/**/*.ts", + "./hooks/**/*.ts", "./src/**/*.svelte", "../components/**/*.ts", "../components/**/*.svelte",