From 684bf8ddc4695bf738539d22e9cc686cf6df7dec Mon Sep 17 00:00:00 2001 From: Esteban Abaroa Date: Tue, 20 Jun 2023 13:50:09 +0000 Subject: [PATCH] add subplebbit pages to feed state string --- src/hooks/useFeedStateString.js | 21 ++++++++++++++++++++- src/hooks/useStateString.js | 1 - 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/hooks/useFeedStateString.js b/src/hooks/useFeedStateString.js index 23b316f0..d853ad05 100644 --- a/src/hooks/useFeedStateString.js +++ b/src/hooks/useFeedStateString.js @@ -24,6 +24,16 @@ const useFeedStateString = (subplebbits) => { addClientUrl(subplebbit.clients.chainProviders[chainTicker][clientUrl], clientUrl) } } + // find subplebbit pages states + if (subplebbit?.posts?.clients) { + for (const clientType in subplebbit.posts.clients) { + for (const sortType in subplebbit.posts.clients[clientType]) { + for (const clientUrl in subplebbit.posts.clients[clientType][sortType]) { + addClientUrl(subplebbit.posts.clients[clientType][sortType][clientUrl], clientUrl) + } + } + } + } } return [...clientUrls] } @@ -35,6 +45,15 @@ const useFeedStateString = (subplebbits) => { const states = {} for (const subplebbit of subplebbits) { states[subplebbit?.updatingState] = (states[subplebbit?.updatingState] || 0) + 1 + // find subplebbit pages states + for (const clientType in subplebbit?.posts?.clients) { + for (const sortType in subplebbit.posts.clients[clientType]) { + for (const clientUrl in subplebbit.posts.clients[clientType][sortType]) { + const state = subplebbit.posts.clients[clientType][sortType][clientUrl].state + states[state] = (states[state] || 0) + 1 + } + } + } } // e.g. Resolving 2 addresses from infura.io, fetching 2 IPNS, 1 IPFS from cloudflare-ipfs.com, ipfs.io @@ -58,7 +77,7 @@ const useFeedStateString = (subplebbits) => { if (states['fetching-ipns']) { stateString += ', ' } - stateString += `${states['fetching-ipfs']} IPNS` + stateString += `${states['fetching-ipfs']} IPFS` } const clientUrls = getClientUrls(/ipfs|ipns/) if (clientUrls.length) { diff --git a/src/hooks/useStateString.js b/src/hooks/useStateString.js index 15fffb46..69a75634 100644 --- a/src/hooks/useStateString.js +++ b/src/hooks/useStateString.js @@ -39,7 +39,6 @@ const useStateString = (commentOrSubplebbit) => { continue } state += `-page-${sortType}` - console.log(clientType, sortType, clientUrl, state) if (!states[state]) { states[state] = [] }