diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index 11d7552..908e0e5 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -50,6 +50,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { const [isVirtualPianoVisible, setVirtualPianoVisible] = useState(false); const [time, setTime] = useState(0); const [score, setScore] = useState(0); // Between 0 and 100 + const [midiKeyboardFound, setMidiKeyboardFound] = useState(); const partitionRessources = useQuery(["partition", songId], () => API.getPartitionRessources(songId) ); @@ -94,7 +95,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { toast.show({ description: 'No MIDI Keyboard found' }); return; } - toast.show({ description: `MIDI ready!`, placement: 'top' }); + setMidiKeyboardFound(true); let inputIndex = 0; webSocket.current = new WebSocket(scoroBaseApiUrl); webSocket.current.onopen = () => { @@ -254,9 +255,7 @@ const PlayView = ({ songId, type, route }: RouteProps) => { Rolling in the Deep - - }/> + {midiKeyboardFound && <> } onPress={() => { @@ -273,12 +272,13 @@ const PlayView = ({ songId, type, route }: RouteProps) => { setVirtualPianoVisible(!isVirtualPianoVisible); }}/> {Math.floor(time / 60000)}:{Math.floor((time % 60000) / 1000).toFixed(0).toString().padStart(2, '0')} - } onPress={() => { onEnd(); navigation.navigate('Score', { songId: song.data.id }); }}/> + } diff --git a/front/views/ScoreView.tsx b/front/views/ScoreView.tsx index 1cb16ac..d5280a7 100644 --- a/front/views/ScoreView.tsx +++ b/front/views/ScoreView.tsx @@ -18,14 +18,17 @@ const ScoreView = ({ songId, route }: RouteProps) => { () => API.getArtist(songQuery.data!.artistId!), { enabled: songQuery.data != undefined } ); - const songScoreQuery = useQuery(["score", songId], () => API.getUserPlayHistory() - .then((history) => history.find((h) => h.songID == songId )!)); + const songHistoryQuery = useQuery(["song", "history"], () => API.getUserPlayHistory()); // const perfoamnceRecommandationsQuery = useQuery(['song', props.songId, 'score', 'latest', 'recommendations'], () => API.getLastSongPerformanceScore(props.songId)); const recommendations = useQuery(['song', 'recommendations'], () => API.getUserRecommendations()); - if (!recommendations.data || !songScoreQuery.data || !songQuery.data || (songQuery.data.artistId && !artistQuery.data)) { + if (!recommendations.data || !songHistoryQuery.data || !songQuery.data || (songQuery.data.artistId && !artistQuery.data)) { return ; } + const songScore = songHistoryQuery.data.find((history) => history.songID == songId); + if (!songScore) { + return
; + } return {songQuery.data.name} @@ -54,7 +57,7 @@ const ScoreView = ({ songId, route }: RouteProps) => { t + ' : '}/> - {songScoreQuery.data.score + "pts"} + {songScore.score + "pts"}