From b84ee11f45fa7cc8056a2d4217d1cc0e47844ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 5 Sep 2023 18:05:15 +0200 Subject: [PATCH] Fix de arthur --- front/views/PlayView.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index d3f0bf0..2e9c0d6 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -1,4 +1,5 @@ /* eslint-disable no-mixed-spaces-and-tabs */ +import { StackActions } from '@react-navigation/native'; import React, { useEffect, useRef, useState } from 'react'; import { SafeAreaView, Platform, Animated } from 'react-native'; import * as ScreenOrientation from 'expo-screen-orientation'; @@ -117,7 +118,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { stopwatch.stop(); if (webSocket.current?.readyState != WebSocket.OPEN) { console.warn('onEnd: Websocket not open'); - navigation.navigate('Home'); + navigation.dispatch(StackActions.replace('Home')); return; } webSocket.current?.send( @@ -164,7 +165,10 @@ const PlayView = ({ songId, type, route }: RouteProps) => { if (data.type == 'end') { endMsgReceived = true; webSocket.current?.close(); - navigation.navigate('Score', { songId: song.data!.id, ...data }); + console.log('End message received stack action'); + navigation.dispatch( + StackActions.replace('Score', { songId: song.data!.id, ...data }) + ); return; } const points = data.info.score; @@ -238,7 +242,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { return () => { ScreenOrientation.unlockAsync().catch(() => {}); - onEnd(); + stopwatch.stop(); clearInterval(interval); }; }, []);