mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(board status): resolve offline indicators with strict community refs
This commit is contained in:
@@ -49,8 +49,14 @@ let latestValue: ReturnType<typeof useIsCommunityOffline>;
|
||||
let container: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
const HookHarness = ({ community }: { community?: { address?: string; state?: string; updatedAt?: number; updatingState?: string } }) => {
|
||||
latestValue = useIsCommunityOffline(community as never);
|
||||
const HookHarness = ({
|
||||
community,
|
||||
communityAddressHint,
|
||||
}: {
|
||||
community?: { address?: string; name?: string; publicKey?: string; state?: string; updatedAt?: number; updatingState?: string };
|
||||
communityAddressHint?: string;
|
||||
}) => {
|
||||
latestValue = useIsCommunityOffline(community as never, communityAddressHint);
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -62,9 +68,12 @@ const flushEffects = async (count = 3) => {
|
||||
}
|
||||
};
|
||||
|
||||
const renderHook = async (community?: { address?: string; state?: string; updatedAt?: number; updatingState?: string }) => {
|
||||
const renderHook = async (
|
||||
community?: { address?: string; name?: string; publicKey?: string; state?: string; updatedAt?: number; updatingState?: string },
|
||||
communityAddressHint?: string,
|
||||
) => {
|
||||
await act(async () => {
|
||||
root.render(createElement(HookHarness, { community }));
|
||||
root.render(createElement(HookHarness, { community, communityAddressHint }));
|
||||
});
|
||||
await flushEffects();
|
||||
};
|
||||
@@ -153,6 +162,24 @@ describe('useIsCommunityOffline', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('tracks strict-community objects with a canonical address hint instead of the undefined key', async () => {
|
||||
await renderHook({ name: 'music.eth', publicKey: '12D3KooWBoardKey', state: 'updating', updatingState: 'fetching' }, 'music.eth');
|
||||
|
||||
expect(testState.requestedAddresses).toEqual(['music.eth']);
|
||||
expect(testState.initializeMock).toHaveBeenCalledWith('music.eth');
|
||||
expect(testState.setOfflineStateMock).toHaveBeenCalledWith('music.eth', {
|
||||
state: 'updating',
|
||||
updatedAt: undefined,
|
||||
updatingState: 'fetching',
|
||||
});
|
||||
expect(latestValue).toEqual({
|
||||
isOffline: false,
|
||||
isOnlineStatusLoading: true,
|
||||
offlineIconClass: 'yellowOfflineIcon',
|
||||
offlineTitle: 'downloading board...',
|
||||
});
|
||||
});
|
||||
|
||||
it('treats recently updated boards as online', async () => {
|
||||
const freshUpdatedAt = 1_704_067_205;
|
||||
testState.communityOfflineState = {
|
||||
|
||||
Reference in New Issue
Block a user