From 393782b4b80762c27c423831f34b7a6b425b0041 Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Tue, 5 Dec 2023 10:38:57 +0100 Subject: [PATCH] Front: Fix state management at end of play --- front/components/ScoreModal.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/front/components/ScoreModal.tsx b/front/components/ScoreModal.tsx index 4b30db6..2d1e1db 100644 --- a/front/components/ScoreModal.tsx +++ b/front/components/ScoreModal.tsx @@ -3,6 +3,7 @@ import ButtonBase from './UI/ButtonBase'; import { Translate, TranslationKey, translate } from '../i18n/i18n'; import { Play, Star1 } from 'iconsax-react-native'; import { useNavigation } from '../Navigation'; +import { StackActions } from '@react-navigation/native'; type ScoreModalProps = { songId: number; @@ -61,7 +62,7 @@ const ScoreModal = (props: ScoreModalProps) => { /> ))} - {score}% + {Math.max(score, 0)}% {props.precision}% @@ -95,7 +96,9 @@ const ScoreModal = (props: ScoreModalProps) => { icon={Play} type="outlined" title={translate('playAgain')} - onPress={() => navigation.navigate('Play', { songId: props.songId })} + onPress={() => + navigation.dispatch(StackActions.replace('Play', { songId: props.songId })) + } />