Skip to content

Commit

Permalink
Enable filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-mn-yral committed Jan 5, 2024
1 parent 29a30bd commit 9a5018c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/experiments/src/routes/loadFirstVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
12 changes: 5 additions & 7 deletions packages/web-client/src/lib/helpers/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export async function getTopPosts(
}
}

//@ts-ignore
async function filterBets(
posts: PostScoreIndexItem[],
): Promise<PostScoreIndexItem[]> {
Expand Down Expand Up @@ -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)}`,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"./vite.config.ts",
"./src/**/*.js",
"./src/**/*.ts",
"./hooks/**/*.ts",
"./src/**/*.svelte",
"../components/**/*.ts",
"../components/**/*.svelte",
Expand Down

0 comments on commit 9a5018c

Please sign in to comment.