diff --git a/front/Navigation.tsx b/front/Navigation.tsx
index 915796d..2768f64 100644
--- a/front/Navigation.tsx
+++ b/front/Navigation.tsx
@@ -7,7 +7,6 @@ import SongLobbyView from './views/SongLobbyView';
import AuthenticationView from './views/AuthenticationView';
import HomeView from './views/HomeView';
import SearchView from './views/SearchView';
-import PartitionView from './views/PartitionView';
import SetttingsNavigator from './views/SettingsView';
import { useQuery } from 'react-query';
import API from './API';
@@ -27,7 +26,6 @@ export const protectedRoutes = <>
-
>;
export const publicRoutes =
diff --git a/front/components/PartitionVisualizer/PartitionVisualizer.tsx b/front/components/PartitionVisualizer/PartitionVisualizer.tsx
index 1dcaae8..7528291 100644
--- a/front/components/PartitionVisualizer/PartitionVisualizer.tsx
+++ b/front/components/PartitionVisualizer/PartitionVisualizer.tsx
@@ -10,9 +10,7 @@ type PartitionVisualizerProps = {
};
const PartitionVisualizer = ({ songId }: PartitionVisualizerProps) => {
- const partitionRessources = useQuery(["partition"], () =>
- API.getPartitionRessources(songId)
- );
+
if (!partitionRessources.data) {
return (
@@ -22,7 +20,7 @@ const PartitionVisualizer = ({ songId }: PartitionVisualizerProps) => {
);
}
return (
-
+
);
};
diff --git a/front/components/Translate.tsx b/front/components/Translate.tsx
index 9941ebd..6588540 100644
--- a/front/components/Translate.tsx
+++ b/front/components/Translate.tsx
@@ -2,7 +2,6 @@ import { Text } from "native-base";
import { translate } from "../i18n/i18n";
import { en } from "../i18n/Translations";
import { RootState, useSelector } from "../state/Store";
-import { Text } from "native-base";
type TranslateProps = {
translationKey: keyof typeof en;
diff --git a/front/views/PartitionView.tsx b/front/views/PartitionView.tsx
deleted file mode 100644
index aa8a824..0000000
--- a/front/views/PartitionView.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import React from "react";
-import { Box } from "native-base";
-import API from "../API";
-import PartitionVisualizer from "../components/PartitionVisualizer/PartitionVisualizer";
-
-const PartitionView = () => {
-
- return (
-
-
-
- );
-};
-
-export default PartitionView;
diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx
index a78b9e4..2d350fb 100644
--- a/front/views/PlayView.tsx
+++ b/front/views/PlayView.tsx
@@ -9,6 +9,8 @@ import API from '../API';
import LoadingComponent from '../components/Loading';
import Constants from 'expo-constants';
import { useStopwatch } from 'react-timer-hook';
+import PartitionVisualizer from '../components/PartitionVisualizer/PartitionVisualizer';
+import SlideView from '../components/PartitionVisualizer/SlideView';
type PlayViewProps = {
songId: number
@@ -21,6 +23,9 @@ const PlayView = ({ songId }: PlayViewProps) => {
const webSocket = useRef();
const timer = useStopwatch({ autoStart: false });
const [paused, setPause] = useState();
+ const partitionRessources = useQuery(["partition"], () =>
+ API.getPartitionRessources(songId)
+ );
const onPause = () => {
timer.pause();
@@ -33,6 +38,7 @@ const PlayView = ({ songId }: PlayViewProps) => {
}
const onResume = () => {
setPause(false);
+ timer.start();
webSocket.current?.send(JSON.stringify({
type: "pause",
paused: false,
@@ -66,11 +72,15 @@ const PlayView = ({ songId }: PlayViewProps) => {
timer.start();
};
webSocket.current.onmessage = (message) => {
- const data = JSON.parse(message.data);
- if (data.type == 'end') {
- navigation.navigate('Score');
- } else if (data.song_launched == undefined) {
- toast.show({ description: data, placement: 'top', colorScheme: 'secondary' });
+ try {
+ const data = JSON.parse(message.data);
+ if (data.type == 'end') {
+ navigation.navigate('Score');
+ } else if (data.song_launched == undefined) {
+ toast.show({ description: data, placement: 'top', colorScheme: 'secondary' });
+ }
+ } catch {
+
}
}
setPause(false);
@@ -106,7 +116,7 @@ const PlayView = ({ songId }: PlayViewProps) => {
}, [])
const score = 20;
- if (!song.data) {
+ if (!song.data || !partitionRessources.data) {
return
@@ -114,6 +124,7 @@ const PlayView = ({ songId }: PlayViewProps) => {
return (
+