Cleanup CI and added check for error in scoro messages

This commit is contained in:
Clément Le Bihan
2023-11-30 15:19:58 +01:00
parent 6018028afd
commit 683984efe9
3 changed files with 56 additions and 72 deletions
+42 -46
View File
@@ -1,48 +1,44 @@
{ {
"expo": { "expo": {
"name": "Chromacase", "name": "Chromacase",
"slug": "Chromacase", "slug": "Chromacase",
"version": "1.0.0", "version": "1.0.0",
"orientation": "portrait", "orientation": "portrait",
"icon": "./assets/icon.png", "icon": "./assets/icon.png",
"userInterfaceStyle": "light", "userInterfaceStyle": "light",
"splash": { "splash": {
"image": "./assets/splash.png", "image": "./assets/splash.png",
"resizeMode": "cover", "resizeMode": "cover",
"backgroundColor": "#ffffff" "backgroundColor": "#ffffff"
}, },
"assetBundlePatterns": [ "assetBundlePatterns": ["**/*"],
"**/*" "ios": {
], "supportsTablet": true
"ios": { },
"supportsTablet": true "android": {
}, "adaptiveIcon": {
"android": { "foregroundImage": "./assets/icon.png",
"adaptiveIcon": { "backgroundColor": "#ffffff"
"foregroundImage": "./assets/icon.png", },
"backgroundColor": "#ffffff" "permissions": ["android.permission.RECORD_AUDIO"],
}, "package": "com.arthichaud.Chromacase"
"permissions": [ },
"android.permission.RECORD_AUDIO" "web": {
], "favicon": "./assets/favicon.png"
"package": "com.arthichaud.Chromacase" },
}, "extra": {
"web": { "eas": {
"favicon": "./assets/favicon.png" "projectId": "dade8e5e-3e2c-49f7-98c5-cf8834c7ebb2"
}, }
"extra": { },
"eas": { "plugins": [
"projectId": "dade8e5e-3e2c-49f7-98c5-cf8834c7ebb2" [
} "expo-image-picker",
}, {
"plugins": [ "photosPermission": "The app accesses your photos to let you set your personal avatar."
[ }
"expo-image-picker", ]
{ ],
"photosPermission": "The app accesses your photos to let you set your personal avatar." "owner": "arthi-chaud"
} }
]
],
"owner": "arthi-chaud"
}
} }
+6 -8
View File
@@ -2,7 +2,6 @@ import * as React from 'react';
import { View } from 'react-native'; import { View } from 'react-native';
import API from '../../API'; import API from '../../API';
import { useQuery } from '../../Queries'; import { useQuery } from '../../Queries';
import { PianoCC } from '../../views/PlayView';
import Animated, { useSharedValue, withTiming, Easing } from 'react-native-reanimated'; import Animated, { useSharedValue, withTiming, Easing } from 'react-native-reanimated';
import { CursorInfoItem } from '../../models/SongCursorInfos'; import { CursorInfoItem } from '../../models/SongCursorInfos';
import { PianoNotes } from '../../state/SoundPlayerSlice'; import { PianoNotes } from '../../state/SoundPlayerSlice';
@@ -15,8 +14,8 @@ export type ParitionMagicProps = {
timestamp: number; timestamp: number;
songID: number; songID: number;
onEndReached: () => void; onEndReached: () => void;
onError: (err: string) => void; onError?: (err: string) => void;
onReady: () => void; onReady?: () => void;
}; };
const getSVGURL = (songID: number) => { const getSVGURL = (songID: number) => {
@@ -52,7 +51,6 @@ const PartitionMagic = ({
const [endPartitionReached, setEndPartitionReached] = React.useState(false); const [endPartitionReached, setEndPartitionReached] = React.useState(false);
const [isPartitionSvgLoaded, setIsPartitionSvgLoaded] = React.useState(false); const [isPartitionSvgLoaded, setIsPartitionSvgLoaded] = React.useState(false);
const partitionOffset = useSharedValue(0); const partitionOffset = useSharedValue(0);
// const pianoCC = React.useContext(PianoCC);
const pianoSounds = React.useRef<Record<string, Audio.Sound> | null>(null); const pianoSounds = React.useRef<Record<string, Audio.Sound> | null>(null);
const cursorPaddingVertical = 10; const cursorPaddingVertical = 10;
const cursorPaddingHorizontal = 3; const cursorPaddingHorizontal = 3;
@@ -94,17 +92,17 @@ const PartitionMagic = ({
}, [data]); }, [data]);
React.useEffect(() => { React.useEffect(() => {
if (isError) { if (onError && isError) {
onError('Error while loading partition'); onError('Error while loading partition');
return; return;
} }
}, [isError]); }, [onError, isError]);
React.useEffect(() => { React.useEffect(() => {
if (isPartitionSvgLoaded && !isLoading) { if (onReady && isPartitionSvgLoaded && !isLoading) {
onReady(); onReady();
} }
}, [isPartitionSvgLoaded, isLoading]); }, [onReady, isPartitionSvgLoaded, isLoading]);
React.useEffect(() => { React.useEffect(() => {
if (endPartitionReached) { if (endPartitionReached) {
+8 -18
View File
@@ -1,6 +1,6 @@
/* eslint-disable no-mixed-spaces-and-tabs */ /* eslint-disable no-mixed-spaces-and-tabs */
import { StackActions } from '@react-navigation/native'; import { StackActions } from '@react-navigation/native';
import React, { useEffect, useRef, useState, createContext } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { SafeAreaView, Platform } from 'react-native'; import { SafeAreaView, Platform } from 'react-native';
import Animated, { import Animated, {
useSharedValue, useSharedValue,
@@ -15,7 +15,7 @@ import { Text, Row, View, useToast } from 'native-base';
import { RouteProps, useNavigation } from '../Navigation'; import { RouteProps, useNavigation } from '../Navigation';
import { useQuery } from '../Queries'; import { useQuery } from '../Queries';
import API from '../API'; import API from '../API';
import LoadingComponent, { LoadingView } from '../components/Loading'; import { LoadingView } from '../components/Loading';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { RootState } from '../state/Store'; import { RootState } from '../state/Store';
import { Translate, translate } from '../i18n/i18n'; import { Translate, translate } from '../i18n/i18n';
@@ -24,7 +24,6 @@ import { useStopwatch } from 'react-use-precision-timer';
import { MIDIAccess, MIDIMessageEvent, requestMIDIAccess } from '@arthi-chaud/react-native-midi'; import { MIDIAccess, MIDIMessageEvent, requestMIDIAccess } from '@arthi-chaud/react-native-midi';
import * as Linking from 'expo-linking'; import * as Linking from 'expo-linking';
import url from 'url'; import url from 'url';
import { PianoCanvasContext } from '../models/PianoGame';
import PartitionMagic from '../components/Play/PartitionMagic'; import PartitionMagic from '../components/Play/PartitionMagic';
import useColorScheme from '../hooks/colorScheme'; import useColorScheme from '../hooks/colorScheme';
import { LinearGradient } from 'expo-linear-gradient'; import { LinearGradient } from 'expo-linear-gradient';
@@ -82,13 +81,11 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
const stopwatch = useStopwatch(); const stopwatch = useStopwatch();
const [time, setTime] = useState(0); const [time, setTime] = useState(0);
const songHistory = useQuery(API.getSongHistory(songId)); const songHistory = useQuery(API.getSongHistory(songId));
const [partitionRendered, setPartitionRendered] = useState(false); // Used to know when partitionview can render
const [score, setScore] = useState(0); // Between 0 and 100 const [score, setScore] = useState(0); // Between 0 and 100
// const fadeAnim = useRef(new Animated.Value(0)).current; // const fadeAnim = useRef(new Animated.Value(0)).current;
const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000; const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000;
const [midiKeyboardFound, setMidiKeyboardFound] = useState<boolean>(); const [midiKeyboardFound, setMidiKeyboardFound] = useState<boolean>();
// first number is the note, the other is the time when pressed on release the key is removed // first number is the note, the other is the time when pressed on release the key is removed
const [pressedKeys, setPressedKeys] = useState<Map<number, number>>(new Map()); // [note, time]
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const [streak, setStreak] = useState(0); const [streak, setStreak] = useState(0);
const scoreMessageScale = useSharedValue(0); const scoreMessageScale = useSharedValue(0);
@@ -177,6 +174,11 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
webSocket.current.onmessage = (message) => { webSocket.current.onmessage = (message) => {
try { try {
const data = JSON.parse(message.data); const data = JSON.parse(message.data);
if (data.error) {
console.error('Scoro msg: ', data.error);
toast.show({ description: 'Scoro: ' + data.error });
return;
}
if (data.type == 'end') { if (data.type == 'end') {
endMsgReceived = true; endMsgReceived = true;
webSocket.current?.close(); webSocket.current?.close();
@@ -229,17 +231,6 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
input.onmidimessage = (message) => { input.onmidimessage = (message) => {
const { command, note } = parseMidiMessage(message); const { command, note } = parseMidiMessage(message);
const keyIsPressed = command == 9; const keyIsPressed = command == 9;
if (keyIsPressed) {
setPressedKeys((prev) => {
prev.set(note, getElapsedTime());
return prev;
});
} else {
setPressedKeys((prev) => {
prev.delete(note);
return prev;
});
}
webSocket.current?.send( webSocket.current?.send(
JSON.stringify({ JSON.stringify({
@@ -428,7 +419,6 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
<PartitionMagic <PartitionMagic
timestamp={time} timestamp={time}
songID={song.data.id} songID={song.data.id}
onReady={() => setPartitionRendered(true)}
onEndReached={() => { onEndReached={() => {
setTimeout(() => { setTimeout(() => {
onEnd(); onEnd();
@@ -443,7 +433,7 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
score={score} score={score}
time={time} time={time}
paused={paused} paused={paused}
// disabled={!midiKeyboardFound} disabled={!midiKeyboardFound}
song={song.data} song={song.data}
onEnd={onEnd} onEnd={onEnd}
onPause={onPause} onPause={onPause}