perf(popular-threads): show board-count loading state for popular threads

This commit is contained in:
plebeius
2026-03-08 17:36:55 +08:00
parent 08ec9f31ff
commit 71b0b0fa42
2 changed files with 13 additions and 1 deletions
@@ -139,4 +139,12 @@ describe('use-state-string', () => {
expect(latestValue).toBe('Resolving 2 addresses from ens.example.com, downloading 2 boards, 1 threads, 1 page from gateway.example.com, ipfs.io'); expect(latestValue).toBe('Resolving 2 addresses from ens.example.com, downloading 2 boards, 1 threads, 1 page from gateway.example.com, ipfs.io');
}); });
it('shows an immediate board-specific loading string before detailed multi-board states arrive', () => {
act(() => {
root.render(createElement(FeedStateStringHarness, { addresses: ['music-posting.eth', 'tech-posting.eth'] }));
});
expect(latestValue).toBe('Downloading 2 boards');
});
}); });
+5 -1
View File
@@ -157,12 +157,16 @@ export const useFeedStateString = (subplebbitAddresses?: string[]): string | und
} }
} }
if (!stateString && subplebbitAddresses?.length) {
stateString = `downloading ${subplebbitAddresses.length} boards`;
}
// capitalize first letter // capitalize first letter
stateString = stateString.charAt(0).toUpperCase() + stateString.slice(1); stateString = stateString.charAt(0).toUpperCase() + stateString.slice(1);
// if string is empty, return undefined instead // if string is empty, return undefined instead
return stateString === '' ? undefined : stateString; return stateString === '' ? undefined : stateString;
}, [states, subplebbitAddress]); }, [states, subplebbitAddress, subplebbitAddresses]);
if (singleSubplebbitFeedStateString) { if (singleSubplebbitFeedStateString) {
return singleSubplebbitFeedStateString; return singleSubplebbitFeedStateString;