Skip to content

Commit

Permalink
Merge pull request #131 from millicast/bug_fix/android_tv_reset_user_…
Browse files Browse the repository at this point in the history
…input_screen

fixed an issue to reset user input screen when navigating back from M…
  • Loading branch information
tarunkgarg authored Feb 19, 2024
2 parents a91cf05 + 3693024 commit e676ed0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/screens/multiview/MultiView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
AppState,
Pressable,
DeviceEventEmitter,
BackHandler,
} from 'react-native';
import { RTCView } from 'react-native-webrtc';
import { useSelector, useDispatch } from 'react-redux';
Expand Down Expand Up @@ -55,10 +56,25 @@ export const MultiView = ({ navigation }) => {
const margin = margins(columnsNumber, false);
const labelLayout = margins(columnsNumber, true);

const navigateToUserInputScreen = () => {
navigation.reset({
index: 0,
routes: [{ name: Routes.UserInput }],
});
return true;
};

useEffect(() => {
BackHandler.addEventListener('hardwareBackPress', navigateToUserInputScreen);
return () => {
BackHandler.removeEventListener('hardwareBackPress', navigateToUserInputScreen);
};
}, []);

useEffect(() => {
const subscription = DeviceEventEmitter.addListener('event.errorView.close', () => {
dispatch({ type: 'viewer/setError', payload: null });
navigation.goBack();
navigateToUserInputScreen();
});

return () => {
Expand Down

0 comments on commit e676ed0

Please sign in to comment.