mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(feed): clarify loading states
This commit is contained in:
@@ -172,6 +172,30 @@ describe('use-state-string', () => {
|
||||
expect(latestValue).toBe('Downloading board via IPFS');
|
||||
});
|
||||
|
||||
it('formats single-board initializing feed states as board loading copy', () => {
|
||||
testState.community = {
|
||||
state: 'initializing',
|
||||
};
|
||||
|
||||
act(() => {
|
||||
root.render(createElement(FeedStateStringHarness, { addresses: ['music-posting.eth'] }));
|
||||
});
|
||||
|
||||
expect(latestValue).toBe('Loading board');
|
||||
});
|
||||
|
||||
it('keeps multi-board feeds on multi-board loading copy while the single community hook initializes', () => {
|
||||
testState.community = {
|
||||
state: 'initializing',
|
||||
};
|
||||
|
||||
act(() => {
|
||||
root.render(createElement(FeedStateStringHarness, { addresses: ['music-posting.eth', 'tech-posting.eth'] }));
|
||||
});
|
||||
|
||||
expect(latestValue).toBe('Downloading 2 boards (music-posting.eth, tech-posting.eth)');
|
||||
});
|
||||
|
||||
it('aggregates multi-board feed states across address resolution, threads, and pages', () => {
|
||||
testState.communitiesStates = {
|
||||
'fetching-ipfs': {
|
||||
|
||||
@@ -67,6 +67,8 @@ const sanitizeSingleFeedLoadingState = (stateString?: string): string | undefine
|
||||
}
|
||||
|
||||
return stateString
|
||||
.replace(/\bInitializing\b/g, 'Loading board')
|
||||
.replace(/\binitializing\b/g, 'loading board')
|
||||
.replace(/\bDownloading thread\b/g, 'Downloading board')
|
||||
.replace(/\bdownloading thread\b/g, 'downloading board')
|
||||
.replace(/\bLoading thread\b/g, 'Loading board')
|
||||
@@ -134,7 +136,8 @@ export const useFeedStateString = (communityAddresses?: string[]): string | unde
|
||||
const communityAddress = communityAddresses?.length === 1 ? communityAddresses[0] : undefined;
|
||||
const communityIdentifier = communityAddress ? communities[0] : undefined;
|
||||
const community = useCommunity(communityIdentifier ? { community: communityIdentifier } : undefined);
|
||||
const singleCommunityFeedStateString = sanitizeSingleFeedLoadingState(useStateString(community));
|
||||
const rawSingleCommunityFeedStateString = useStateString(communityAddress ? community : undefined);
|
||||
const singleCommunityFeedStateString = communityAddress ? sanitizeSingleFeedLoadingState(rawSingleCommunityFeedStateString) : undefined;
|
||||
|
||||
// multiple community feed state string
|
||||
const { states } = useCommunitiesStates({ communities });
|
||||
|
||||
Reference in New Issue
Block a user