Use the new history api on the front

This commit is contained in:
2023-05-23 17:10:58 +09:00
parent 3585c259a0
commit b80d4e20c1
5 changed files with 16 additions and 13 deletions
+3
View File
@@ -14,6 +14,9 @@
nodePackages."@nestjs/cli"
nodePackages.npm
nodejs-slim
yarn
python3
pkg-config
];
shellHook = with pkgs; ''
export PRISMA_MIGRATION_ENGINE_BINARY="${prisma-engines}/bin/migration-engine"
+3 -3
View File
@@ -331,10 +331,10 @@ export default class API {
* Retrieve a song's play history
* @param songId the id to find the song
*/
public static async getSongHistory(songId: number): Promise<SongHistory[]> {
public static async getSongHistory(songId: number): Promise<{best: number, history: SongHistory[]}> {
return API.fetch({
route: `/history`,
}).then((data: SongHistory[]) => data.filter((entry) => entry.songID == songId))
route: `/song${songId}/history`,
});
}
/**
+2 -2
View File
@@ -84,8 +84,8 @@
"noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
"useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
"noUnusedLocals": false, /* Enable error reporting when a local variables aren't read. */
"noUnusedParameters": false, /* Raise an error when a function parameter isn't read */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
+4 -4
View File
@@ -14,13 +14,13 @@ const ScoreView = ({ songId, route }: RouteProps<ScoreViewProps>) => {
const theme = useTheme();
const navigation = useNavigation();
const songQuery = useQuery(['song', songId], () => API.getSong(songId));
const artistQuery = useQuery(['song', songId],
const artistQuery = useQuery(['song', songId, "artist"],
() => API.getArtist(songQuery.data!.artistId!),
{ enabled: songQuery.data != undefined }
);
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());
const recommendations = useQuery(['song', songId, 'recommendations'], () => API.getUserRecommendations());
const artistRecommendations = useQueries(recommendations.data
?.filter(({ artistId }) => artistId !== null)
.map((song) => ({
@@ -36,7 +36,7 @@ const ScoreView = ({ songId, route }: RouteProps<ScoreViewProps>) => {
if (!songScore) {
return <Center>
<Translate translationKey="unknownError"/>
<TextButton
<TextButton
translate={{ translationKey: 'backBtn' }}
onPress={() => navigation.navigate('Home')}
/>
@@ -57,7 +57,7 @@ const ScoreView = ({ songId, route }: RouteProps<ScoreViewProps>) => {
<Column style={{ justifyContent: 'space-evenly', flexGrow: 1 }}>
{/*<Row style={{ alignItems: 'center' }}>
<Text bold fontSize='xl'>
</Text>
<Translate translationKey='goodNotes' format={(t) => ' ' + t}/>
</Row>
+4 -4
View File
@@ -59,13 +59,13 @@ const SongLobbyView = (props: RouteProps<SongLobbyProps>) => {
<Text bold fontSize='lg'>
<Translate translationKey='bestScore'/>
</Text>
<Text>{scoresQuery.data!.sort()[0]?.score ?? 0}</Text>
<Text>{scoresQuery.data!.best ?? 0}</Text>
</Box>
<Box style={{ flexDirection: 'column', alignItems: 'center' }}>
<Text bold fontSize='lg'>
<Translate translationKey='lastScore'/>
</Text>
<Text>{scoresQuery.data!.slice(-1)[0]?.score ?? 0}</Text>
<Text>{scoresQuery.data!.history[0]?.score ?? 0}</Text>
</Box>
</Box>
{/* <Text style={{ paddingBottom: 10 }}>{songQuery.data!.description}</Text> */}
@@ -79,7 +79,7 @@ const SongLobbyView = (props: RouteProps<SongLobbyProps>) => {
</Box>
<PresenceTransition visible={chaptersOpen} initial={{ opacity: 0 }}>
{ chaptersQuery.isLoading && <LoadingComponent/>}
{ !chaptersQuery.isLoading &&
{ !chaptersQuery.isLoading &&
<VStack flex={1} space={4} padding="4" divider={<Divider />}>
{ chaptersQuery.data!.map((chapter) =>
<Box key={chapter.id} flexGrow={1} flexDirection='row' justifyContent="space-between">
@@ -96,4 +96,4 @@ const SongLobbyView = (props: RouteProps<SongLobbyProps>) => {
)
}
export default SongLobbyView;
export default SongLobbyView;