Skip to content

Commit 882f40e

Browse files
authored
fix: activation problems on android (#344)
1 parent 80e81ce commit 882f40e

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/components/SuccessErrorBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const SuccessErrorBanner = (props: Props) => {
3131

3232
const renderPending =
3333
<>
34-
<Text style={{fontWeight: 'bold', color: MD3Colors.neutral0, textAlign: 'center'}}>{props.pendingContent}</Text>
34+
<Text style={{fontWeight: 'bold', color: MD3Colors.neutralVariant100, textAlign: 'center'}}>{props.pendingContent}</Text>
3535
<Spacer height={20}/>
3636
<View style={{maxWidth: 300, width: '100%', alignSelf: 'center', justifyContent: 'center'}}>
3737
<ProgressBar indeterminate={true} />

src/screens/AccountActivationScreen.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {useTranslation} from 'react-i18next';
44
import {SuccessErrorBanner} from '../components/SuccessErrorBanner';
55
import RestAPI from '../dao/RestAPI';
66
import {BaseNavigatorProps} from '../navigation/NavigationRoutes';
7-
import {login} from '../redux/features/authSlice';
7+
import {login, logout} from '../redux/features/authSlice';
88
import {useAppDispatch} from '../redux/hooks';
99
import {LoginBackdrop} from './LoginScreen/LoginBackdrop';
1010

@@ -14,6 +14,7 @@ export const AccountActivationScreen = (props: Props) => {
1414
const [activationError, setActivationError] = useState(false);
1515
const [activationSuccess, setActivationSuccess] = useState(false);
1616

17+
1718
const dispatch = useAppDispatch();
1819

1920
useEffect(() => {
@@ -22,13 +23,30 @@ export const AccountActivationScreen = (props: Props) => {
2223
return;
2324
}
2425

25-
RestAPI.activateAccount(props.route.params.activationId).then(() => {
26-
setActivationSuccess(true);
27-
dispatch(login());
28-
props.navigation.navigate('default');
29-
}).catch(() => {
30-
setActivationError(true);
31-
});
26+
const activationTimer = setTimeout(() => {
27+
RestAPI.activateAccount(props.route.params.activationId).then(() => {
28+
setActivationSuccess(true);
29+
dispatch(login());
30+
props.navigation.navigate('default');
31+
}).catch(() => {
32+
// Sometimes when this sceeen is accessed via deep links, the activity is mounted twice.
33+
// In this case the activation link is already expired. Check if the user is logged in
34+
35+
RestAPI.getUserInfo().then((userinfo) => {
36+
if (userinfo.email) {
37+
console.info('got userinfo, logging in');
38+
dispatch(login());
39+
props.navigation.navigate('default');
40+
}
41+
}).catch((error) => {
42+
console.error('Login failed', error);
43+
dispatch(logout());
44+
setActivationError(true);
45+
});
46+
});
47+
}, 1000);
48+
49+
return (() => clearTimeout(activationTimer));
3250
}, [props.route.params.activationId]);
3351

3452
return (

src/screens/LoginScreen/SignupScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const SignupScreen = (props: Props) => {
6868
<Checkbox
6969
status={termsAccepted ? 'checked' : 'unchecked'}
7070
color={colors.primary}
71-
uncheckedColor={colors.surface}
71+
uncheckedColor={MD3Colors.neutralVariant100}
7272
onPress={() => setTermsAccepted(!termsAccepted)} />
7373
<Text
7474
onPress={() => setTermsAccepted(!termsAccepted)}

0 commit comments

Comments
 (0)