This commit is contained in:
Clément Le Bihan
2023-12-27 21:49:59 +01:00
parent af0531bb0c
commit 495380ec43
10 changed files with 53 additions and 26 deletions

View File

@@ -125,7 +125,7 @@ export default function Hoverable({
};
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return React.cloneElement(React.Children.only(children) as any, {
...webProps,
// if child is Touchable

View File

@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { Slider, Text, View, IconButton, Icon } from 'native-base';
import { Slider, View, IconButton, Icon } from 'native-base';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { Audio } from 'expo-av';
import { VolumeHigh, VolumeSlash } from 'iconsax-react-native';

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { Translate, translate } from '../i18n/i18n';
import { Box, Text, VStack, Progress, Stack } from 'native-base';
import { Translate } from '../i18n/i18n';
import { Box, VStack, Progress, Stack } from 'native-base';
import { useNavigation } from '../Navigation';
import Card from '../components/Card';
import UserAvatar from './UserAvatar';

View File

@@ -1,19 +1,11 @@
import Song from '../../models/Song';
import React from 'react';
import { Image, Platform, View } from 'react-native';
import {
Pressable,
Text,
IconButton,
PresenceTransition,
Icon,
useBreakpointValue,
} from 'native-base';
import { Pressable, Text, PresenceTransition, Icon, useBreakpointValue } from 'native-base';
import { LikeButton } from './SongCardInfoLikeBtn';
import { Ionicons } from '@expo/vector-icons';
import { useQuery } from '../../Queries';
import API from '../../API';
import { MaterialIcons } from '@expo/vector-icons';
import { useLikeSongMutation } from '../../utils/likeSongMutation';
import Hoverable from '../Hoverable';

View File

@@ -30,7 +30,11 @@ export const SongValidator = yup
artist: yup.lazy(() => ArtistValidator.default(undefined)).optional(),
album: yup.lazy(() => AlbumValidator.default(undefined)).optional(),
genre: yup.lazy(() => GenreValidator.default(undefined)).optional(),
likedByUsers: yup.lazy(() => yup.array(yup.object({ userId: yup.number().required() })).default(undefined)).optional(),
likedByUsers: yup
.lazy(() =>
yup.array(yup.object({ userId: yup.number().required() })).default(undefined)
)
.optional(),
})
.concat(ModelValidator)
.transform((song: Song) => ({

View File

@@ -66,6 +66,7 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-transform-export-namespace-from": "^7.22.11",
"@types/fbjs": "^3.0.10",
"@types/lodash": "^4.14.199",
"@types/react": "~18.2.14",
"@typescript-eslint/eslint-plugin": "^6.7.3",

View File

@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from "react-query"
import API from "../API";
import { useMutation, useQueryClient } from 'react-query';
import API from '../API';
/**
* Mutation to like/unlike a song
@@ -7,13 +7,13 @@ import API from "../API";
export const useLikeSongMutation = () => {
const queryClient = useQueryClient();
return useMutation(({ songId, like }: {songId: number, like: boolean}) => {
const apiCall = like ? API.addLikedSong : API.removeLikedSong
return useMutation(({ songId, like }: { songId: number; like: boolean }) => {
const apiCall = like ? API.addLikedSong : API.removeLikedSong;
return apiCall(songId).then(() => {
queryClient.invalidateQueries({ queryKey: ['liked songs'] })
queryClient.invalidateQueries({ queryKey: ['songs'] })
queryClient.invalidateQueries({ queryKey: [songId] })
queryClient.invalidateQueries({ queryKey: ['liked songs'] });
queryClient.invalidateQueries({ queryKey: ['songs'] });
queryClient.invalidateQueries({ queryKey: [songId] });
});
});
}
};

View File

@@ -10,7 +10,9 @@ import GoldenRatio from '../../components/V2/GoldenRatio';
// eslint-disable-next-line @typescript-eslint/ban-types
const HomeView = (props: RouteProps<{}>) => {
const suggestionsQuery = useQuery(API.getSongSuggestions(['artist', 'SongHistory', 'likedByUsers']));
const suggestionsQuery = useQuery(
API.getSongSuggestions(['artist', 'likedByUsers', 'SongHistory'])
);
const navigation = useNavigation();
const screenSize = useBreakpointValue({ base: 'small', md: 'big' });
const isPhone = screenSize === 'small';

View File

@@ -12,7 +12,7 @@ import {
Route,
SceneRendererProps,
} from 'react-native-tab-view';
import { HeartEdit, UserEdit, Notification, SecurityUser, FolderCross } from 'iconsax-react-native';
import { HeartEdit, UserEdit, SecurityUser, FolderCross } from 'iconsax-react-native';
import { Scene } from 'react-native-tab-view/lib/typescript/src/types';
import { RouteProps } from '../../Navigation';
import ScaffoldCC from '../../components/UI/ScaffoldCC';

View File

@@ -3169,6 +3169,13 @@
"@types/qs" "*"
"@types/serve-static" "*"
"@types/fbjs@^3.0.10":
version "3.0.10"
resolved "https://registry.yarnpkg.com/@types/fbjs/-/fbjs-3.0.10.tgz#e837db996533e28e862d8fd09b3e1c44d7f0e252"
integrity sha512-becmqsrRvB0qwgEYy96i9cN48w8YwOeaMhpyT/sbkSuWX27LDXPESBrgSFKkgcIdk39jqcPlLdLljT2y2OcyTg==
dependencies:
"@types/jsdom" "*"
"@types/glob@^7.1.1":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
@@ -3228,6 +3235,15 @@
dependencies:
"@types/istanbul-lib-report" "*"
"@types/jsdom@*":
version "21.1.6"
resolved "https://registry.yarnpkg.com/@types/jsdom/-/jsdom-21.1.6.tgz#bcbc7b245787ea863f3da1ef19aa1dcfb9271a1b"
integrity sha512-/7kkMsC+/kMs7gAYmmBR9P0vGTnOoLhQhyhQJSlXGI5bzTHp6xdo0TtKWQAsz6pmSAeVqKSbqeyP6hytqr9FDw==
dependencies:
"@types/node" "*"
"@types/tough-cookie" "*"
parse5 "^7.0.0"
"@types/json-schema@*", "@types/json-schema@^7.0.12", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9":
version "7.0.15"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
@@ -3342,6 +3358,11 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"
integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==
"@types/tough-cookie@*":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304"
integrity sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==
"@types/use-sync-external-store@^0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz#b6725d5f4af24ace33b36fafd295136e75509f43"
@@ -5365,7 +5386,7 @@ entities@^2.0.0:
resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==
entities@^4.2.0:
entities@^4.2.0, entities@^4.4.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48"
integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==
@@ -9198,6 +9219,13 @@ parse-png@^2.1.0:
dependencies:
pngjs "^3.3.0"
parse5@^7.0.0:
version "7.1.2"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.1.2.tgz#0736bebbfd77793823240a23b7fc5e010b7f8e32"
integrity sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==
dependencies:
entities "^4.4.0"
parseurl@~1.3.2, parseurl@~1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"