From af714b64ce5bc7f1f03fb438b1857d7cd20ffcea Mon Sep 17 00:00:00 2001 From: harshbaz Date: Thu, 8 Feb 2024 19:25:39 +0530 Subject: [PATCH] Update --- package-lock.json | 162 ++++++------------ packages/declarations/package.json | 3 + packages/web-client/src/lib/helpers/feed.ts | 22 ++- .../(feed)/feed/[id=videoId]/+page.svelte | 9 +- .../(feed)/hotornot/[id=videoId]/+page.svelte | 8 +- 5 files changed, 81 insertions(+), 123 deletions(-) diff --git a/package-lock.json b/package-lock.json index d59ba9f2e..9a62ab81c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -774,20 +774,7 @@ "ms": "^2.1.1" } }, - "node_modules/@dfinity/identity-secp256k1": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/identity-secp256k1/-/identity-secp256k1-0.21.4.tgz", - "integrity": "sha512-8kvNshRHu/EEG3MVjpMfQLM5IsJGCHE4tM81sHXNxabSOzRFH7Oeyo/YLn7CFLPELTvdjLXxazjylu6VcjCr2Q==", - "dependencies": { - "@dfinity/agent": "^0.21.4", - "@noble/curves": "^1.3.0", - "@noble/hashes": "^1.3.1", - "bip39": "^3.1.0", - "bs58check": "^3.0.1", - "hdkey": "^2.1.0" - } - }, - "node_modules/@dfinity/identity-secp256k1/node_modules/@dfinity/agent": { + "node_modules/@dfinity/agent": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.21.4.tgz", "integrity": "sha512-k5k8v1BmDE8RStC22FtuqbFzMLaQAQL3cE/wF45ZMKP4WmBBmCPss75RDgIVGiFwLGEKKKXE1muHQDy9g+m5yQ==", @@ -804,20 +791,31 @@ "@dfinity/principal": "^0.21.4" } }, - "node_modules/@dfinity/identity-secp256k1/node_modules/@dfinity/candid": { + "node_modules/@dfinity/candid": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.21.4.tgz", "integrity": "sha512-BRdgLQjPbqEZDRIR985jpy92uwhdBn4mN2D8StMKyOXQLmR6hKSD0p/P2b632Sh7zPUY8HuiA8njpMZ67JEyAg==", - "peer": true, "peerDependencies": { "@dfinity/principal": "^0.21.4" } }, - "node_modules/@dfinity/identity-secp256k1/node_modules/@dfinity/principal": { + "node_modules/@dfinity/identity-secp256k1": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/@dfinity/identity-secp256k1/-/identity-secp256k1-0.21.4.tgz", + "integrity": "sha512-8kvNshRHu/EEG3MVjpMfQLM5IsJGCHE4tM81sHXNxabSOzRFH7Oeyo/YLn7CFLPELTvdjLXxazjylu6VcjCr2Q==", + "dependencies": { + "@dfinity/agent": "^0.21.4", + "@noble/curves": "^1.3.0", + "@noble/hashes": "^1.3.1", + "bip39": "^3.1.0", + "bs58check": "^3.0.1", + "hdkey": "^2.1.0" + } + }, + "node_modules/@dfinity/principal": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.21.4.tgz", "integrity": "sha512-r9d+9BYZdFMzrq1+zcdIg6q6tlWeZ9SKnakVdhQ21qUJ6iDe0yxDlah6k9QKEh6fVsg2yv95nID++nqEosvt1Q==", - "peer": true, "dependencies": { "@noble/hashes": "^1.3.1" } @@ -12968,7 +12966,10 @@ "packages/declarations": { "name": "@hnn/declarations", "version": "0.2.2", - "license": "ISC" + "license": "ISC", + "dependencies": { + "@dfinity/agent": "^0.21.4" + } }, "packages/experiments": { "name": "@hnn/experiments", @@ -13213,23 +13214,6 @@ "vitest": "^1.2.2" } }, - "packages/web-client/node_modules/@dfinity/agent": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.21.4.tgz", - "integrity": "sha512-k5k8v1BmDE8RStC22FtuqbFzMLaQAQL3cE/wF45ZMKP4WmBBmCPss75RDgIVGiFwLGEKKKXE1muHQDy9g+m5yQ==", - "dependencies": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.1", - "base64-arraybuffer": "^0.2.0", - "borc": "^2.1.1", - "buffer": "^6.0.3", - "simple-cbor": "^0.4.1" - }, - "peerDependencies": { - "@dfinity/candid": "^0.21.4", - "@dfinity/principal": "^0.21.4" - } - }, "packages/web-client/node_modules/@dfinity/auth-client": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.21.4.tgz", @@ -13248,14 +13232,6 @@ "resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz", "integrity": "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==" }, - "packages/web-client/node_modules/@dfinity/candid": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.21.4.tgz", - "integrity": "sha512-BRdgLQjPbqEZDRIR985jpy92uwhdBn4mN2D8StMKyOXQLmR6hKSD0p/P2b632Sh7zPUY8HuiA8njpMZ67JEyAg==", - "peerDependencies": { - "@dfinity/principal": "^0.21.4" - } - }, "packages/web-client/node_modules/@dfinity/identity": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.21.4.tgz", @@ -13271,14 +13247,6 @@ "@peculiar/webcrypto": "^1.4.0" } }, - "packages/web-client/node_modules/@dfinity/principal": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.21.4.tgz", - "integrity": "sha512-r9d+9BYZdFMzrq1+zcdIg6q6tlWeZ9SKnakVdhQ21qUJ6iDe0yxDlah6k9QKEh6fVsg2yv95nID++nqEosvt1Q==", - "dependencies": { - "@noble/hashes": "^1.3.1" - } - }, "packages/web-client/node_modules/@sentry-internal/tracing": { "version": "7.100.1", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.100.1.tgz", @@ -14078,6 +14046,25 @@ } } }, + "@dfinity/agent": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.21.4.tgz", + "integrity": "sha512-k5k8v1BmDE8RStC22FtuqbFzMLaQAQL3cE/wF45ZMKP4WmBBmCPss75RDgIVGiFwLGEKKKXE1muHQDy9g+m5yQ==", + "requires": { + "@noble/curves": "^1.2.0", + "@noble/hashes": "^1.3.1", + "base64-arraybuffer": "^0.2.0", + "borc": "^2.1.1", + "buffer": "^6.0.3", + "simple-cbor": "^0.4.1" + } + }, + "@dfinity/candid": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.21.4.tgz", + "integrity": "sha512-BRdgLQjPbqEZDRIR985jpy92uwhdBn4mN2D8StMKyOXQLmR6hKSD0p/P2b632Sh7zPUY8HuiA8njpMZ67JEyAg==", + "requires": {} + }, "@dfinity/identity-secp256k1": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/identity-secp256k1/-/identity-secp256k1-0.21.4.tgz", @@ -14089,37 +14076,14 @@ "bip39": "^3.1.0", "bs58check": "^3.0.1", "hdkey": "^2.1.0" - }, - "dependencies": { - "@dfinity/agent": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.21.4.tgz", - "integrity": "sha512-k5k8v1BmDE8RStC22FtuqbFzMLaQAQL3cE/wF45ZMKP4WmBBmCPss75RDgIVGiFwLGEKKKXE1muHQDy9g+m5yQ==", - "requires": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.1", - "base64-arraybuffer": "^0.2.0", - "borc": "^2.1.1", - "buffer": "^6.0.3", - "simple-cbor": "^0.4.1" - } - }, - "@dfinity/candid": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.21.4.tgz", - "integrity": "sha512-BRdgLQjPbqEZDRIR985jpy92uwhdBn4mN2D8StMKyOXQLmR6hKSD0p/P2b632Sh7zPUY8HuiA8njpMZ67JEyAg==", - "peer": true, - "requires": {} - }, - "@dfinity/principal": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.21.4.tgz", - "integrity": "sha512-r9d+9BYZdFMzrq1+zcdIg6q6tlWeZ9SKnakVdhQ21qUJ6iDe0yxDlah6k9QKEh6fVsg2yv95nID++nqEosvt1Q==", - "peer": true, - "requires": { - "@noble/hashes": "^1.3.1" - } - } + } + }, + "@dfinity/principal": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.21.4.tgz", + "integrity": "sha512-r9d+9BYZdFMzrq1+zcdIg6q6tlWeZ9SKnakVdhQ21qUJ6iDe0yxDlah6k9QKEh6fVsg2yv95nID++nqEosvt1Q==", + "requires": { + "@noble/hashes": "^1.3.1" } }, "@esbuild-plugins/node-globals-polyfill": { @@ -14851,7 +14815,10 @@ } }, "@hnn/declarations": { - "version": "file:packages/declarations" + "version": "file:packages/declarations", + "requires": { + "@dfinity/agent": "^0.21.4" + } }, "@hnn/experiments": { "version": "file:packages/experiments", @@ -15054,19 +15021,6 @@ "vitest": "^1.2.2" }, "dependencies": { - "@dfinity/agent": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-0.21.4.tgz", - "integrity": "sha512-k5k8v1BmDE8RStC22FtuqbFzMLaQAQL3cE/wF45ZMKP4WmBBmCPss75RDgIVGiFwLGEKKKXE1muHQDy9g+m5yQ==", - "requires": { - "@noble/curves": "^1.2.0", - "@noble/hashes": "^1.3.1", - "base64-arraybuffer": "^0.2.0", - "borc": "^2.1.1", - "buffer": "^6.0.3", - "simple-cbor": "^0.4.1" - } - }, "@dfinity/auth-client": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/auth-client/-/auth-client-0.21.4.tgz", @@ -15082,12 +15036,6 @@ } } }, - "@dfinity/candid": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-0.21.4.tgz", - "integrity": "sha512-BRdgLQjPbqEZDRIR985jpy92uwhdBn4mN2D8StMKyOXQLmR6hKSD0p/P2b632Sh7zPUY8HuiA8njpMZ67JEyAg==", - "requires": {} - }, "@dfinity/identity": { "version": "0.21.4", "resolved": "https://registry.npmjs.org/@dfinity/identity/-/identity-0.21.4.tgz", @@ -15098,14 +15046,6 @@ "borc": "^2.1.1" } }, - "@dfinity/principal": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-0.21.4.tgz", - "integrity": "sha512-r9d+9BYZdFMzrq1+zcdIg6q6tlWeZ9SKnakVdhQ21qUJ6iDe0yxDlah6k9QKEh6fVsg2yv95nID++nqEosvt1Q==", - "requires": { - "@noble/hashes": "^1.3.1" - } - }, "@sentry-internal/tracing": { "version": "7.100.1", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.100.1.tgz", diff --git a/packages/declarations/package.json b/packages/declarations/package.json index 4c0303e27..f8d22ad4b 100644 --- a/packages/declarations/package.json +++ b/packages/declarations/package.json @@ -5,6 +5,9 @@ "scripts": { "fetch": "sh ./fetch.sh" }, + "dependencies": { + "@dfinity/agent": "^0.21.4" + }, "keywords": [], "author": "", "license": "ISC" diff --git a/packages/web-client/src/lib/helpers/feed.ts b/packages/web-client/src/lib/helpers/feed.ts index 998ff8b3b..1fedb33f0 100644 --- a/packages/web-client/src/lib/helpers/feed.ts +++ b/packages/web-client/src/lib/helpers/feed.ts @@ -141,12 +141,15 @@ export async function getTopPosts( from: number, numberOfPosts: number = 10, filterViewed = false, + showNsfw = false, ): Promise { 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) @@ -213,19 +216,22 @@ async function filterBets( export async function getHotOrNotPosts( from: number, numberOfPosts: number = 10, + showNsfw = false, ): Promise { 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)}`, diff --git a/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.svelte b/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.svelte index 786cc0ebf..7670f3f53 100644 --- a/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.svelte +++ b/packages/web-client/src/routes/(feed)/feed/[id=videoId]/+page.svelte @@ -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' @@ -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(() => { diff --git a/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.svelte b/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.svelte index 3f482f054..c3658b244 100644 --- a/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.svelte +++ b/packages/web-client/src/routes/(feed)/hotornot/[id=videoId]/+page.svelte @@ -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' @@ -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(() => {