Auth timeout (#1263)
This commit is contained in:
parent
ddb32a3614
commit
3283f55e7e
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text, useInput } from 'ink';
|
||||||
import Spinner from 'ink-spinner';
|
import Spinner from 'ink-spinner';
|
||||||
import { Colors } from '../colors.js';
|
import { Colors } from '../colors.js';
|
||||||
|
|
||||||
|
@ -18,11 +18,17 @@ export function AuthInProgress({
|
||||||
}: AuthInProgressProps): React.JSX.Element {
|
}: AuthInProgressProps): React.JSX.Element {
|
||||||
const [timedOut, setTimedOut] = useState(false);
|
const [timedOut, setTimedOut] = useState(false);
|
||||||
|
|
||||||
|
useInput((_, key) => {
|
||||||
|
if (key.escape) {
|
||||||
|
onTimeout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
setTimedOut(true);
|
setTimedOut(true);
|
||||||
onTimeout();
|
onTimeout();
|
||||||
}, 30000);
|
}, 180000);
|
||||||
|
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [onTimeout]);
|
}, [onTimeout]);
|
||||||
|
@ -42,7 +48,7 @@ export function AuthInProgress({
|
||||||
) : (
|
) : (
|
||||||
<Box>
|
<Box>
|
||||||
<Text>
|
<Text>
|
||||||
<Spinner type="dots" /> Waiting for auth...
|
<Spinner type="dots" /> Waiting for auth... (Press ESC to cancel)
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue