forked from vergnet/application-amicale
		
	Fix state errors
This commit is contained in:
		
							parent
							
								
									541c002558
								
							
						
					
					
						commit
						ffa4cfa376
					
				
					 5 changed files with 18 additions and 5 deletions
				
			
		|  | @ -22,7 +22,7 @@ type Props = { | |||
|   onResetPasswordPress: () => void; | ||||
| }; | ||||
| 
 | ||||
| const ICON_AMICALE = require('../../../assets/amicale.png'); | ||||
| const ICON_AMICALE = require('../../../../assets/amicale.png'); | ||||
| 
 | ||||
| const styles = StyleSheet.create({ | ||||
|   card: { | ||||
|  |  | |||
|  | @ -33,6 +33,7 @@ function LogoutDialog(props: PropsType) { | |||
|   const onClickAccept = async (): Promise<void> => { | ||||
|     return new Promise((resolve: () => void) => { | ||||
|       onLogout(); | ||||
|       props.onDismiss(); | ||||
|       resolve(); | ||||
|     }); | ||||
|   }; | ||||
|  |  | |||
|  | @ -128,7 +128,10 @@ function VoteSelect(props: Props) { | |||
|         message={i18n.t('screens.vote.select.dialogMessage')} | ||||
|       /> | ||||
|       <ErrorDialog | ||||
|         visible={currentError.status !== REQUEST_STATUS.SUCCESS} | ||||
|         visible={ | ||||
|           currentError.status !== REQUEST_STATUS.SUCCESS || | ||||
|           currentError.code !== undefined | ||||
|         } | ||||
|         onDismiss={onErrorDialogDismiss} | ||||
|         status={currentError.status} | ||||
|         code={currentError.code} | ||||
|  |  | |||
|  | @ -407,7 +407,10 @@ function EquipmentRentScreen(props: Props) { | |||
|         /> | ||||
| 
 | ||||
|         <ErrorDialog | ||||
|           visible={currentError.status !== REQUEST_STATUS.SUCCESS} | ||||
|           visible={ | ||||
|             currentError.status !== REQUEST_STATUS.SUCCESS || | ||||
|             currentError.code !== undefined | ||||
|           } | ||||
|           onDismiss={onErrorDialogDismiss} | ||||
|           status={currentError.status} | ||||
|           code={currentError.code} | ||||
|  |  | |||
|  | @ -35,11 +35,13 @@ import LoginForm from '../../components/Amicale/Login/LoginForm'; | |||
| import { useFocusEffect, useNavigation } from '@react-navigation/native'; | ||||
| import { TabRoutes } from '../../navigation/TabNavigator'; | ||||
| import { useShouldShowMascot } from '../../context/preferencesContext'; | ||||
| import { useLogin } from '../../context/loginContext'; | ||||
| 
 | ||||
| type Props = StackScreenProps<MainStackParamsList, 'login'>; | ||||
| 
 | ||||
| function LoginScreen(props: Props) { | ||||
|   const navigation = useNavigation<StackNavigationProp<any>>(); | ||||
|   const { setLogin } = useLogin(); | ||||
|   const [loading, setLoading] = useState(false); | ||||
|   const [nextScreen, setNextScreen] = useState<string | undefined>(undefined); | ||||
|   const [mascotDialogVisible, setMascotDialogVisible] = useState(false); | ||||
|  | @ -88,11 +90,12 @@ function LoginScreen(props: Props) { | |||
|    * Navigates to the screen specified in navigation parameters or simply go back tha stack. | ||||
|    * Saves in user preferences to not show the login banner again. | ||||
|    */ | ||||
|   const handleSuccess = () => { | ||||
|   const handleSuccess = (token: string) => { | ||||
|     // Do not show the home login banner again
 | ||||
|     if (homeMascot.shouldShow) { | ||||
|       homeMascot.setShouldShow(false); | ||||
|     } | ||||
|     setLogin(token); | ||||
|     if (!nextScreen) { | ||||
|       navigation.goBack(); | ||||
|     } else { | ||||
|  | @ -138,7 +141,10 @@ function LoginScreen(props: Props) { | |||
|             emotion={MASCOT_STYLE.NORMAL} | ||||
|           /> | ||||
|           <ErrorDialog | ||||
|             visible={currentError.status !== REQUEST_STATUS.SUCCESS} | ||||
|             visible={ | ||||
|               currentError.status !== REQUEST_STATUS.SUCCESS || | ||||
|               currentError.code !== undefined | ||||
|             } | ||||
|             onDismiss={hideErrorDialog} | ||||
|             status={currentError.status} | ||||
|             code={currentError.code} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue