mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-03 07:22:31 +02:00
Be more gentle with frontend typing + go back to fire-and-forget for cracked room creation
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user