Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-mn-yral committed Feb 8, 2024
1 parent 57ac1da commit af714b6
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 123 deletions.
162 changes: 51 additions & 111 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/declarations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"scripts": {
"fetch": "sh ./fetch.sh"
},
"dependencies": {
"@dfinity/agent": "^0.21.4"
},
"keywords": [],
"author": "",
"license": "ISC"
Expand Down
22 changes: 14 additions & 8 deletions packages/web-client/src/lib/helpers/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ export async function getTopPosts(
from: number,
numberOfPosts: number = 10,
filterViewed = false,
showNsfw = false,
): Promise<FeedResponse> {
try {
const res =
await postCache().get_top_posts_aggregated_from_canisters_on_this_network_for_home_feed(
await postCache().get_top_posts_aggregated_from_canisters_on_this_network_for_home_feed_cursor(
BigInt(from),
BigInt(from + numberOfPosts),
BigInt(numberOfPosts),
[showNsfw],
[],
)
if ('Ok' in res) {
const nonReportedPosts = await filterReportedPosts(res.Ok)
Expand Down Expand Up @@ -213,19 +216,22 @@ async function filterBets(
export async function getHotOrNotPosts(
from: number,
numberOfPosts: number = 10,
showNsfw = false,
): Promise<FeedResponse> {
try {
const res =
await postCache().get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed(
await postCache().get_top_posts_aggregated_from_canisters_on_this_network_for_hot_or_not_feed_cursor(
BigInt(from),
BigInt(from + numberOfPosts),
BigInt(numberOfPosts),
[showNsfw],
[],
)
if ('Ok' in res) {
// const notBetPosts = await filterBets(res.Ok)
const notStuckPosts = await filterStuckCanisterPosts(res.Ok)
const notBetPosts = await filterBets(res.Ok)
const notStuckPosts = await filterStuckCanisterPosts(notBetPosts)
const notReportedPosts = await filterReportedPosts(notStuckPosts)
// const notWatchedPosts = await filterPosts(notReportedPosts, 'watch-hon')
const populatedRes = await populatePosts(notReportedPosts, false)
const notWatchedPosts = await filterPosts(notReportedPosts, 'watch-hon')
const populatedRes = await populatePosts(notWatchedPosts, false)
if (populatedRes.error) {
throw new Error(
`Error while populating, ${JSON.stringify(populatedRes)}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Log from '$lib/utils/Log'
import { updateURL } from '$lib/utils/feedUrl'
import { handleParams } from '$lib/utils/params'
import { joinArrayUniquely } from '$lib/utils/video'
import { homeFeedVideos, playerState } from '$lib/stores/app'
import { appPrefs, homeFeedVideos, playerState } from '$lib/stores/app'
import { removeSplashScreen } from '$lib/stores/popups'
import { onMount, tick } from 'svelte'
import { debounce } from 'throttle-debounce'
Expand Down Expand Up @@ -54,7 +54,12 @@ async function fetchNextVideos(force = false) {
source: 'feed.fetchNextVideos',
})
loading = true
const res = await getTopPosts(fetchedVideosCount, fetchCount, true)
const res = await getTopPosts(
fetchedVideosCount,
fetchCount,
true,
$appPrefs.showNsfwVideos,
)
if (res.error) {
if (errorCount < 4) {
loadTimeout = setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { updateURL } from '$lib/utils/feedUrl'
import Log from '$lib/utils/Log'
import { handleParams } from '$lib/utils/params'
import { joinArrayUniquely } from '$lib/utils/video'
import { hotOrNotFeedVideos, playerState } from '$lib/stores/app'
import { appPrefs, hotOrNotFeedVideos, playerState } from '$lib/stores/app'
import { removeSplashScreen } from '$lib/stores/popups'
import { onMount, tick } from 'svelte'
import type { PageData } from './$types'
Expand Down Expand Up @@ -52,7 +52,11 @@ async function fetchNextVideos(force = false) {
source: 'hotOrNot.fetchNextVideos',
})
loading = true
const res = await getHotOrNotPosts(fetchedVideosCount, fetchCount)
const res = await getHotOrNotPosts(
fetchedVideosCount,
fetchCount,
$appPrefs.showNsfwVideos,
)
if (res.error) {
if (errorCount < 4) {
loadTimeout = setTimeout(() => {
Expand Down

0 comments on commit af714b6

Please sign in to comment.