Fix empty board loading state and browser P2P patch (#1175)

* fix(board): show loaded empty boards

* fix(p2p): patch browser hooks runtime

* fix(board): stop flash loading for explicit empty boards

* fix(board): wait for feed on preloaded empty pages
This commit is contained in:
Tommaso Casaburi
2026-06-18 18:54:48 +07:00
committed by GitHub
parent 9896c4400b
commit eb47214f08
9 changed files with 821 additions and 240 deletions
+103
View File
@@ -36,6 +36,7 @@ type TestComment = {
type TestCommunity = {
error?: Error;
nameResolved?: boolean;
updatedAt?: number;
posts?: {
pageCids?: Record<string, string>;
pages?: Record<string, { comments?: TestComment[]; nextCid?: string }>;
@@ -687,6 +688,43 @@ describe('Board', () => {
expect(container.querySelectorAll('[data-testid="loading-ellipsis"]').length).toBe(1);
});
it('renders an empty flash table when a loaded board reports explicit empty page cids', async () => {
testState.directories = [{ address: 'flash-posting.bso', directoryCode: 'f', title: '/f/ - Flash' }];
testState.directoryByAddress = {
'flash-posting.bso': {
address: 'flash-posting.bso',
directoryCode: 'f',
features: { postsPerPage: 50 },
title: '/f/ - Flash',
},
};
testState.resolvedCommunityAddress = 'flash-posting.bso';
testState.feedState = 'fetching-ipns';
testState.hasMore = true;
testState.community = {
error: undefined,
posts: {
pageCids: {},
pages: {},
},
shortAddress: 'flash-posting.bso',
state: 'succeeded',
title: '/f/ - Flash',
updatedAt: 1781773422,
};
testState.communitySnapshot = {
shortAddress: 'flash-posting.bso',
title: '/f/ - Flash',
};
await renderBoard({ initialEntry: '/f', routePath: '/:boardIdentifier/*' });
const table = container.querySelector('#flash-list');
expect(table).toBeTruthy();
expect(table?.textContent).toContain('no posts');
expect(table?.querySelector('[data-testid="loading-ellipsis"]')).toBeNull();
});
it('inserts a nonoko pending account comment after pinned posts on the redirected board index', async () => {
const currentTimestamp = Math.floor(Date.now() / 1000);
testState.feed = [
@@ -1043,6 +1081,71 @@ describe('Board', () => {
expect(container.querySelector('[data-testid="loading-ellipsis"]')).toBeNull();
});
it('keeps loading when an empty preloaded board page finishes before the feed', async () => {
testState.feedStateString = undefined;
testState.feedState = 'fetching-ipns';
testState.hasMore = true;
testState.community = {
error: undefined,
shortAddress: 'music-posting.eth',
state: 'succeeded',
title: '/mu/ - Music',
};
markRawBoardThreadsFullyLoaded();
await renderBoard({ initialEntry: '/mu', routePath: '/:boardIdentifier/*' });
expect(container.textContent).not.toContain('no_threads');
expect(container.querySelector('[data-testid="loading-ellipsis"]')?.textContent).toBe('downloading_board');
expect(container.textContent).toContain('load_more');
});
it('shows no threads when a loaded board reports explicit empty page cids', async () => {
testState.feedStateString = 'Downloading board from peers';
testState.feedState = 'fetching-ipns';
testState.hasMore = true;
testState.community = {
error: undefined,
posts: {
pageCids: {},
pages: {},
},
shortAddress: 'blog.bitsocial.bso',
state: 'succeeded',
title: 'Bitsocial Updates',
updatedAt: 1781773422,
};
testState.communitySnapshot = {
shortAddress: 'blog.bitsocial.bso',
title: 'Bitsocial Updates',
};
await renderBoard({ initialEntry: '/blog.bitsocial.bso', routePath: '/:boardIdentifier/*' });
expect(container.textContent).toContain('no_threads');
expect(container.querySelector('[data-testid="loading-ellipsis"]')).toBeNull();
expect(container.textContent).not.toContain('load_more');
});
it('keeps loading when raw board pages contain threads but the feed has not caught up', async () => {
testState.feedStateString = undefined;
testState.feedState = 'fetching-ipns';
testState.hasMore = true;
testState.community = {
error: undefined,
shortAddress: 'music-posting.eth',
state: 'succeeded',
title: '/mu/ - Music',
};
markRawBoardThreadsFullyLoaded([{ cid: 'post-1' }]);
await renderBoard({ initialEntry: '/mu', routePath: '/:boardIdentifier/*' });
expect(container.textContent).not.toContain('no_threads');
expect(container.querySelector('[data-testid="loading-ellipsis"]')?.textContent).toBe('downloading_board');
expect(container.textContent).toContain('load_more');
});
it('does not show no threads after board metadata loads but raw thread pages are still missing', async () => {
testState.feedStateString = undefined;
testState.feedState = 'succeeded';