Skip to content

Commit

Permalink
chore: useAppSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
OtavioStasiak committed Jan 8, 2025
1 parent bbd5bd5 commit e146b1e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/containers/TwoFactor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { InteractionManager, Text, View } from 'react-native';
import React, { useEffect, useRef, useState } from 'react';
import { AccessibilityInfo, InteractionManager, Text, View } from 'react-native';
import isEmpty from 'lodash/isEmpty';
import { sha256 } from 'js-sha256';
import Modal from 'react-native-modal';
Expand Down Expand Up @@ -66,6 +66,7 @@ const TwoFactor = React.memo(() => {
const [visible, setVisible] = useState(false);
const [data, setData] = useState<EventListenerMethod>({});
const [code, setCode] = useState<string>('');
const overlayRef = useRef(null);

const method = data.method ? methods[data.method] : null;
const isEmail = data.method === 'email';
Expand All @@ -80,7 +81,7 @@ const TwoFactor = React.memo(() => {
}
}
} catch (e) {
log(e)
log(e);
}
};

Expand All @@ -93,7 +94,13 @@ const TwoFactor = React.memo(() => {
}
}, [data]);

const showTwoFactor = (args: EventListenerMethod) => setData(args);
const showTwoFactor = (args: EventListenerMethod) => {
const overlayReactTag = overlayRef.current;
setData(args);
if (overlayReactTag) {
AccessibilityInfo.setAccessibilityFocus(overlayReactTag);
}
};

useEffect(() => {
const listener = EventEmitter.addEventListener(TWO_FACTOR, showTwoFactor);
Expand Down Expand Up @@ -126,6 +133,7 @@ const TwoFactor = React.memo(() => {
<Modal avoidKeyboard useNativeDriver isVisible={visible} hideModalContentWhileAnimating>
<View style={styles.container} testID='two-factor'>
<View
ref={overlayRef}
style={[
styles.content,
isMasterDetail && [sharedStyles.modalFormSheet, styles.tablet],
Expand Down

0 comments on commit e146b1e

Please sign in to comment.