fix(thread update): refresh stale reply caches (#1160)

* fix(thread update): refresh stale reply caches

Evict the current thread comment and known reply-page cache entries before manual refresh so stale local data does not keep replies hidden. Also defer broader multiboard suggestion feeds until the current /all time window is exhausted to reduce renderer pressure.

* fix(thread update): evict alternate reply page caches

* fix(board): hide stale time-window suggestions
This commit is contained in:
Tommaso Casaburi
2026-06-08 14:44:38 +07:00
committed by GitHub
parent 6c660c01cd
commit c2b222c4d5
6 changed files with 299 additions and 19 deletions
+29 -4
View File
@@ -270,11 +270,11 @@ vi.mock('../../../components/error-display/error-display', () => ({
default: ({ error }: { error?: Error }) => createElement('div', { 'data-testid': 'error-display' }, error?.message || 'no-error'),
}));
vi.mock('../../../components/loading-ellipsis', () => ({
vi.mock('../../../components/loading-ellipsis/loading-ellipsis', () => ({
default: ({ string }: { string: string }) => createElement('div', { 'data-testid': 'loading-ellipsis' }, string),
}));
vi.mock('../../../components/board-pagination', () => ({
vi.mock('../../../components/board-pagination/board-pagination', () => ({
default: ({ basePath, currentPage, totalPages }: { basePath: string; currentPage: number; totalPages: number }) =>
createElement('div', { 'data-testid': 'board-pagination' }, `${basePath}:${currentPage}:${totalPages}`),
}));
@@ -283,12 +283,12 @@ vi.mock('../../../components/board-buttons/board-buttons', () => ({
CatalogButton: ({ address }: { address?: string }) => createElement('div', { 'data-testid': 'catalog-button' }, address || 'catalog'),
}));
vi.mock('../../../components/footer', () => ({
vi.mock('../../../components/footer/footer', () => ({
PageFooterDesktop: ({ firstRow }: { firstRow: React.ReactNode }) => createElement('div', { 'data-testid': 'footer-desktop' }, firstRow),
PageFooterMobile: ({ children }: { children: React.ReactNode }) => createElement('div', { 'data-testid': 'footer-mobile' }, children),
}));
vi.mock('../../post', () => ({
vi.mock('../../post/post', () => ({
Post: ({ post }: { post?: TestComment }) => createElement('div', { 'data-testid': 'post' }, post?.cid || post?.content || 'missing-post'),
}));
@@ -957,6 +957,31 @@ describe('Board', () => {
);
});
it('waits to probe broader multiboard suggestions until the current time window is exhausted', async () => {
const now = Math.floor(Date.now() / 1000);
testState.feed = [
{ cid: 'recent-post', communityAddress: 'music-posting.eth', timestamp: now - 12 * 60 * 60 },
{ cid: 'older-post', communityAddress: 'music-posting.eth', timestamp: now - 5 * 24 * 60 * 60 },
];
testState.feedState = 'fetching-ipns';
testState.hasMore = true;
await renderBoard({
boardProps: { viewType: 'all' },
initialEntry: '/all?t=24h',
routePath: '/all/*',
});
expect(testState.feedOptionsCalls).toEqual(
expect.arrayContaining([
expect.objectContaining({ newerThan: 7 * 24 * 60 * 60, communitiesLength: 0 }),
expect.objectContaining({ newerThan: 30 * 24 * 60 * 60, communitiesLength: 0 }),
expect.objectContaining({ newerThan: 365 * 24 * 60 * 60, communitiesLength: 0 }),
]),
);
expect(container.querySelector('[data-testid="expand-time-window-button"]')).toBeNull();
});
it('surfaces board load errors when the feed is empty', async () => {
testState.community = {
error: new Error('board failed'),