Be more gentle with frontend typing + go back to fire-and-forget for cracked room creation

This commit is contained in:
Jack Kingsman
2026-03-09 21:51:07 -07:00
parent 3316f00271
commit c3f1a43a80
4 changed files with 59 additions and 8 deletions
+3 -1
View File
@@ -188,7 +188,9 @@ export function useAppShellProps({
key_type: 'channel',
channel_key: created.key,
});
await fetchUndecryptedCount();
void fetchUndecryptedCount().catch((error) => {
console.error('Failed to refresh undecrypted count after cracked channel create:', error);
});
},
[fetchUndecryptedCount, setChannels]
);
@@ -186,4 +186,40 @@ describe('useAppShellProps', () => {
});
expect(args.fetchUndecryptedCount).toHaveBeenCalledTimes(1);
});
it('does not fail cracked channel creation when undecrypted count refresh rejects', async () => {
mocks.api.createChannel.mockResolvedValue({
key: '22'.repeat(16),
name: 'Found',
is_hashtag: false,
});
mocks.api.getChannels.mockResolvedValue([
publicChannel,
{ ...publicChannel, key: '22'.repeat(16), name: 'Found' },
]);
mocks.api.decryptHistoricalPackets.mockResolvedValue({ decrypted_count: 4 });
const args = createArgs({
fetchUndecryptedCount: vi.fn(async () => {
throw new Error('refresh failed');
}),
});
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
const { result } = renderHook(() => useAppShellProps(args));
await act(async () => {
await result.current.crackerProps.onChannelCreate('Found', '22'.repeat(16));
});
expect(mocks.api.decryptHistoricalPackets).toHaveBeenCalledWith({
key_type: 'channel',
channel_key: '22'.repeat(16),
});
expect(consoleError).toHaveBeenCalledWith(
'Failed to refresh undecrypted count after cracked channel create:',
expect.any(Error)
);
consoleError.mockRestore();
});
});