add state strings for subplebbit pages

This commit is contained in:
Esteban Abaroa
2023-06-20 12:04:46 +00:00
parent 0fc8a386de
commit d9df66fbc2
2 changed files with 146 additions and 126 deletions
+20
View File
@@ -29,6 +29,26 @@ const useStateString = (commentOrSubplebbit) => {
} }
} }
// find subplebbit pages states
if (commentOrSubplebbit?.posts?.clients) {
for (const clientType in commentOrSubplebbit.posts.clients) {
for (const sortType in commentOrSubplebbit.posts.clients[clientType]) {
for (const clientUrl in commentOrSubplebbit.posts.clients[clientType][sortType]) {
let state = commentOrSubplebbit.posts.clients[clientType][sortType][clientUrl].state
if (state === 'stopped') {
continue
}
state += `-page-${sortType}`
console.log(clientType, sortType, clientUrl, state)
if (!states[state]) {
states[state] = []
}
states[state].push(clientUrl)
}
}
}
}
const getClientHost = (clientUrl) => { const getClientHost = (clientUrl) => {
try { try {
clientUrl = new URL(clientUrl).hostname || clientUrl clientUrl = new URL(clientUrl).hostname || clientUrl