From 6da96ed886f760d6c1ccb7792ea7798d220fb4ac Mon Sep 17 00:00:00 2001 From: danis Date: Wed, 6 Sep 2023 17:00:36 +0200 Subject: [PATCH] clean code V --- front/components/SearchBar.tsx | 5 -- front/components/SearchResult.tsx | 126 ------------------------------ front/components/SongRow.tsx | 11 +-- 3 files changed, 1 insertion(+), 141 deletions(-) diff --git a/front/components/SearchBar.tsx b/front/components/SearchBar.tsx index 9bb568e..3ef7d71 100644 --- a/front/components/SearchBar.tsx +++ b/front/components/SearchBar.tsx @@ -42,11 +42,6 @@ const SearchBar = () => { callback: () => updateFilter('all'), id: 'all', }, - { - name: translate('favoriteFilter'), - callback: () => updateFilter('favorite'), - id: 'favorite', - }, { name: translate('artistFilter'), callback: () => updateFilter('artist'), diff --git a/front/components/SearchResult.tsx b/front/components/SearchResult.tsx index 8dd037c..42d031a 100644 --- a/front/components/SearchResult.tsx +++ b/front/components/SearchResult.tsx @@ -39,101 +39,6 @@ const swaToSongCardProps = (song: SongWithArtist) => ({ cover: song.cover ?? 'https://picsum.photos/200', }); -const RowCustom = (props: Parameters[0] & { onPress?: () => void }) => { - const settings = useSelector((state: RootState) => state.settings.local); - const systemColorMode = useColorScheme(); - const colorScheme = settings.colorScheme; - - return ( - - {({ isHovered, isPressed }) => ( - - {props.children} - - )} - - ); -}; - -// type SongRowProps = { -// song: Song | SongWithArtist; // TODO: remove Song -// onPress: () => void; -// }; - -// const SongRow = ({ song, onPress }: SongRowProps) => { -// return ( -// -// -// {song.name} -// -// -// {song.name} -// -// -// {song.artistId ?? 'artist'} -// -// -// -// -// -// ); -// }; - -SongRow.defaultProps = { - onPress: () => {}, -}; - const HomeSearchComponent = () => { const { updateStringQuery } = React.useContext(SearchContext); const { isLoading: isLoadingHistory, data: historyData = [] } = useQuery( @@ -301,35 +206,6 @@ const GenreSearchComponent = (props: ItemSearchComponentProps) => { ); }; -const FavoriteSearchComponent = (props: SongsSearchComponentProps) => { - const { favoriteData } = React.useContext(SearchContext); - const navigation = useNavigation(); - - return ( - - - {translate('favoriteFilter')} - - - {favoriteData?.length ? ( - favoriteData.slice(0, props.maxRows).map((comp, index) => ( - { - API.createSearchHistoryEntry(comp.name, 'song'); - navigation.navigate('Song', { songId: comp.id }); - }} - /> - )) - ) : ( - {translate('errNoResults')} - )} - - - ) -} - const AllComponent = () => { const screenSize = useBreakpointValue({ base: 'small', md: 'big' }); const isMobileView = screenSize == 'small'; @@ -375,8 +251,6 @@ const FilterSwitch = () => { return ; case 'genre': return ; - case 'favorite': - return ; default: return Something very bad happened: {currentFilter}; } diff --git a/front/components/SongRow.tsx b/front/components/SongRow.tsx index 57d1746..5ac3189 100644 --- a/front/components/SongRow.tsx +++ b/front/components/SongRow.tsx @@ -3,18 +3,13 @@ import Song, { SongWithArtist } from "../models/Song"; import RowCustom from "./RowCustom"; import TextButton from "./TextButton"; import { MaterialIcons } from "@expo/vector-icons"; -import API from "../API"; type SongRowProps = { - liked: boolean; song: Song | SongWithArtist; // TODO: remove Song onPress: () => void; }; -const handleLikeButton = { -} - -const SongRow = ({ song, onPress, liked }: SongRowProps) => { +const SongRow = ({ song, onPress }: SongRowProps) => { return ( @@ -28,10 +23,6 @@ const SongRow = ({ song, onPress, liked }: SongRowProps) => { borderColor={'white'} borderWidth={1} /> -