Make OAuth tokens API more resilient

This commit is contained in:
Alex Gleason 2023-01-24 12:00:34 -06:00
parent 845ef1c4d4
commit ad6d03b4eb
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 14 additions and 12 deletions

View file

@ -50,7 +50,7 @@ const MOVE_ACCOUNT_FAIL = 'MOVE_ACCOUNT_FAIL';
const fetchOAuthTokens = () => const fetchOAuthTokens = () =>
(dispatch: AppDispatch, getState: () => RootState) => { (dispatch: AppDispatch, getState: () => RootState) => {
dispatch({ type: FETCH_TOKENS_REQUEST }); dispatch({ type: FETCH_TOKENS_REQUEST });
return api(getState).get('/api/oauth_tokens.json').then(({ data: tokens }) => { return api(getState).get('/api/oauth_tokens').then(({ data: tokens }) => {
dispatch({ type: FETCH_TOKENS_SUCCESS, tokens }); dispatch({ type: FETCH_TOKENS_SUCCESS, tokens });
}).catch(() => { }).catch(() => {
dispatch({ type: FETCH_TOKENS_FAIL }); dispatch({ type: FETCH_TOKENS_FAIL });

View file

@ -45,9 +45,10 @@ const AuthToken: React.FC<IAuthToken> = ({ token, isCurrent }) => {
<Stack space={2}> <Stack space={2}>
<Stack> <Stack>
<Text size='md' weight='medium'>{token.app_name}</Text> <Text size='md' weight='medium'>{token.app_name}</Text>
{token.valid_until && (
<Text size='sm' theme='muted'> <Text size='sm' theme='muted'>
<FormattedDate <FormattedDate
value={new Date(token.valid_until)} value={token.valid_until}
hour12 hour12
year='numeric' year='numeric'
month='short' month='short'
@ -56,6 +57,7 @@ const AuthToken: React.FC<IAuthToken> = ({ token, isCurrent }) => {
minute='2-digit' minute='2-digit'
/> />
</Text> </Text>
)}
</Stack> </Stack>
<div className='flex justify-end'> <div className='flex justify-end'>