This commit is contained in:
Clément Le Bihan
2023-12-05 16:18:05 +01:00
parent 7678776872
commit 69d9a4c499
4 changed files with 34 additions and 28 deletions
+6 -4
View File
@@ -42,7 +42,7 @@ const SongHistory = (props: { quantity: number }) => {
if (acc.length === 0) {
return [curr];
}
if (acc.find((h) => h.song.id === curr.song.id)) {
if (acc.find((h) => h.song!.id === curr.song!.id)) {
return acc;
}
return [...acc, curr];
@@ -59,15 +59,17 @@ const SongHistory = (props: { quantity: number }) => {
) : (
musics.map((song) => (
<View
key={'short-history-tab' + song.id}
key={'short-history-tab' + song!.id}
style={{
paddingHorizontal: 16,
paddingVertical: 10,
flex: 1,
}}
>
<Pressable onPress={() => navigation.navigate('Play', { songId: song.id })}>
<Text numberOfLines={1}>{song.name}</Text>
<Pressable
onPress={() => navigation.navigate('Play', { songId: song!.id })}
>
<Text numberOfLines={1}>{song!.name}</Text>
</Pressable>
</View>
))
+23 -20
View File
@@ -3,27 +3,30 @@ import ResponseHandler from './ResponseHandler';
import { ModelValidator } from './Model';
import { SongValidator } from './Song';
export const SongHistoryItemValidator = yup.object({
songID: yup.number().required(),
song: SongValidator.optional(),
userID: yup.number().required(),
info: yup.object({
good: yup.number().required(),
great: yup.number().required(),
export const SongHistoryItemValidator = yup
.object({
songID: yup.number().required(),
song: SongValidator.optional(),
userID: yup.number().required(),
info: yup
.object({
good: yup.number().required(),
great: yup.number().required(),
score: yup.number().required(),
wrong: yup.number().required(),
missed: yup.number().required(),
perfect: yup.number().required(),
max_score: yup.number().required(),
max_streak: yup.number().required(),
// there's also a current streak key but it doesn't
// conceptually makes sense outside of the played game
})
.required(),
score: yup.number().required(),
wrong: yup.number().required(),
missed: yup.number().required(),
perfect: yup.number().required(),
max_score: yup.number().required(),
max_streak: yup.number().required(),
// there's also a current streak key but it doesn't
// conceptually makes sense outside of the played game
}).required(),
score: yup.number().required(),
playDate: yup.date().required(),
difficulties: yup.mixed().required(),
}).concat(ModelValidator);
playDate: yup.date().required(),
difficulties: yup.mixed().required(),
})
.concat(ModelValidator);
export type SongHistoryItem = yup.InferType<typeof SongHistoryItemValidator>;
export const SongHistoryItemHandler: ResponseHandler<SongHistoryItem> = {
+4 -4
View File
@@ -59,10 +59,10 @@ const HomeView = (props: RouteProps<{}>) => {
playHistoryQuery.data
?.map((x) => x.song)
.map((song) => ({
cover: song.cover,
name: song.name,
songId: song.id,
artistName: song.artist!.name,
cover: song!.cover,
name: song!.name,
songId: song!.id,
artistName: song!.artist!.name,
})) ?? []
}
/>
+1
View File
@@ -86,6 +86,7 @@ const PlayView = ({ songId, route }: RouteProps<PlayViewProps>) => {
const [score, setScore] = useState(0); // Between 0 and 100
// const fadeAnim = useRef(new Animated.Value(0)).current;
const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [midiKeyboardFound, setMidiKeyboardFound] = useState<boolean>();
// first number is the note, the other is the time when pressed on release the key is removed
// eslint-disable-next-line @typescript-eslint/no-unused-vars