Esc to exit privacy screen in error state (#2527)

This commit is contained in:
Tommaso Sciortino 2025-06-29 00:50:53 -07:00 committed by GitHub
parent 19a9b50aab
commit fc21d1cae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { Box, Newline, Text } from 'ink';
import { Box, Newline, Text, useInput } from 'ink';
import { RadioButtonSelect } from '../components/shared/RadioButtonSelect.js';
import { usePrivacySettings } from '../hooks/usePrivacySettings.js';
import { CloudPaidPrivacyNotice } from './CloudPaidPrivacyNotice.js';
@ -23,15 +23,24 @@ export const CloudFreePrivacyNotice = ({
const { privacyState, updateDataCollectionOptIn } =
usePrivacySettings(config);
useInput((input, key) => {
if (privacyState.error && key.escape) {
onExit();
}
});
if (privacyState.isLoading) {
return <Text color={Colors.Gray}>Loading...</Text>;
}
if (privacyState.error) {
return (
<Text color={Colors.AccentRed}>
Error loading Opt-in settings: {privacyState.error}
</Text>
<Box flexDirection="column" marginY={1}>
<Text color={Colors.AccentRed}>
Error loading Opt-in settings: {privacyState.error}
</Text>
<Text color={Colors.Gray}>Press Esc to exit.</Text>
</Box>
);
}