add subplebbit pages to feed state string

This commit is contained in:
Esteban Abaroa
2023-06-20 13:50:09 +00:00
parent b5d685a3c4
commit 684bf8ddc4
2 changed files with 20 additions and 2 deletions
+20 -1
View File
@@ -24,6 +24,16 @@ const useFeedStateString = (subplebbits) => {
addClientUrl(subplebbit.clients.chainProviders[chainTicker][clientUrl], clientUrl) 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] return [...clientUrls]
} }
@@ -35,6 +45,15 @@ const useFeedStateString = (subplebbits) => {
const states = {} const states = {}
for (const subplebbit of subplebbits) { for (const subplebbit of subplebbits) {
states[subplebbit?.updatingState] = (states[subplebbit?.updatingState] || 0) + 1 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 // 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']) { if (states['fetching-ipns']) {
stateString += ', ' stateString += ', '
} }
stateString += `${states['fetching-ipfs']} IPNS` stateString += `${states['fetching-ipfs']} IPFS`
} }
const clientUrls = getClientUrls(/ipfs|ipns/) const clientUrls = getClientUrls(/ipfs|ipns/)
if (clientUrls.length) { if (clientUrls.length) {
-1
View File
@@ -39,7 +39,6 @@ const useStateString = (commentOrSubplebbit) => {
continue continue
} }
state += `-page-${sortType}` state += `-page-${sortType}`
console.log(clientType, sortType, clientUrl, state)
if (!states[state]) { if (!states[state]) {
states[state] = [] states[state] = []
} }