From d01aabe788109c18c997ebe0ed7f01b797fc15b7 Mon Sep 17 00:00:00 2001 From: mathysPaul Date: Mon, 13 Nov 2023 14:34:14 +0100 Subject: [PATCH] [IMP] linter & prettier --- front/components/GtkUI/RawElement.tsx | 30 ++++++++++-- front/components/UI/MusicList.tsx | 17 ++++--- front/views/MusicView.tsx | 49 ++++++++++--------- .../views/settings/NotificationsSettings.tsx | 2 - front/views/settings/PreferencesSettings.tsx | 3 +- front/views/settings/PrivacySettings.tsx | 2 - front/views/settings/SettingsProfile.tsx | 5 +- 7 files changed, 64 insertions(+), 44 deletions(-) diff --git a/front/components/GtkUI/RawElement.tsx b/front/components/GtkUI/RawElement.tsx index e4ffa03..8c3bd33 100644 --- a/front/components/GtkUI/RawElement.tsx +++ b/front/components/GtkUI/RawElement.tsx @@ -1,5 +1,15 @@ import React from 'react'; -import { Box, Button, Column, Icon, Popover, Row, Text, useBreakpointValue, useTheme } from 'native-base'; +import { + Box, + Button, + Column, + Icon, + Popover, + Row, + Text, + useBreakpointValue, + useTheme, +} from 'native-base'; import { Ionicons } from '@expo/vector-icons'; import { ElementProps } from './ElementTypes'; import { @@ -43,9 +53,13 @@ export const RawElement = ({ element }: RawElementProps) => { alignItems: 'center', }} > - {IconElement && - - } + {IconElement && ( + + )} { case 'custom': return data; case 'sectionDropdown': - return ; + return ( + + ); default: return Unknown type; } diff --git a/front/components/UI/MusicList.tsx b/front/components/UI/MusicList.tsx index 6a545f6..ff48b80 100644 --- a/front/components/UI/MusicList.tsx +++ b/front/components/UI/MusicList.tsx @@ -38,10 +38,7 @@ function MusicItemTitleComponent(props: MusicItemTitleProps) { )} {/* Icon with color based on the current color scheme. */} - + ); } @@ -100,7 +97,11 @@ type MusicListProps = { * making it suitable for use cases where the list of items is expected to grow over time. * - The layout and styling are optimized for performance and responsiveness. */ -function MusicListComponent({ initialMusics, loadMoreMusics, musicsPerPage = loadMoreMusics ? 50 : initialMusics.length }: MusicListProps) { +function MusicListComponent({ + initialMusics, + loadMoreMusics, + musicsPerPage = loadMoreMusics ? 50 : initialMusics.length, +}: MusicListProps) { // State initialization for MusicList. // 'allMusics': all music items. // 'displayedMusics': items displayed per page. @@ -113,7 +114,7 @@ function MusicListComponent({ initialMusics, loadMoreMusics, musicsPerPage = loa displayedMusics: initialMusics.slice(0, musicsPerPage), currentPage: 1, loading: false, - hasMoreMusics: initialMusics.length > musicsPerPage || !!loadMoreMusics, + hasMoreMusics: initialMusics.length > musicsPerPage || !!loadMoreMusics, }); const { colors } = useTheme(); const screenSize = useBreakpointValue({ base: 'small', md: 'md', xl: 'xl' }); @@ -138,8 +139,8 @@ function MusicListComponent({ initialMusics, loadMoreMusics, musicsPerPage = loa updatedAllMusics = [...updatedAllMusics, ...newMusics]; hasMoreMusics = newMusics.length > 0; } else { - hasMoreMusics = updatedAllMusics.length > nextEndIndex; - } + hasMoreMusics = updatedAllMusics.length > nextEndIndex; + } setMusicListState((prevState) => ({ ...prevState, diff --git a/front/views/MusicView.tsx b/front/views/MusicView.tsx index a40557a..3e685cb 100644 --- a/front/views/MusicView.tsx +++ b/front/views/MusicView.tsx @@ -1174,29 +1174,34 @@ export const FavoritesMusic = () => { .map((song) => API.getArtist(song.artistId)) ); - const isLoading = playHistoryQuery.isLoading || nextStepQuery.isLoading || - songHistory.some(query => query.isLoading) || - artistsQueries.some(query => query.isLoading); + const isLoading = + playHistoryQuery.isLoading || + nextStepQuery.isLoading || + songHistory.some((query) => query.isLoading) || + artistsQueries.some((query) => query.isLoading); - const musics = nextStepQuery.data - ?.filter((song) => - artistsQueries.find( - (artistQuery) => artistQuery.data?.id === song.artistId - ) - ) - .map((song) => ({ - artist: artistsQueries.find( - (artistQuery) => artistQuery.data?.id === song.artistId - )!.data!.name, - song: song.name, - image: song.cover, - level: 42, - lastScore: 42, - bestScore: 42, - liked: false, - onLike: () => {console.log("onLike")}, - onPlay: () => {console.log("onPlay")}, - })) ?? [] + const musics = + nextStepQuery.data + ?.filter((song) => + artistsQueries.find((artistQuery) => artistQuery.data?.id === song.artistId) + ) + .map((song) => ({ + artist: artistsQueries.find( + (artistQuery) => artistQuery.data?.id === song.artistId + )!.data!.name, + song: song.name, + image: song.cover, + level: 42, + lastScore: 42, + bestScore: 42, + liked: false, + onLike: () => { + console.log('onLike'); + }, + onPlay: () => { + console.log('onPlay'); + }, + })) ?? []; if (isLoading) { return ; diff --git a/front/views/settings/NotificationsSettings.tsx b/front/views/settings/NotificationsSettings.tsx index 408c009..1b4df41 100644 --- a/front/views/settings/NotificationsSettings.tsx +++ b/front/views/settings/NotificationsSettings.tsx @@ -4,8 +4,6 @@ import ElementList from '../../components/GtkUI/ElementList'; import useUserSettings from '../../hooks/userSettings'; import { LoadingView } from '../../components/Loading'; import { Calendar1, MonitorMobbile, Send2, Warning2 } from 'iconsax-react-native'; -import useColorScheme from '../../hooks/colorScheme'; -import { useTheme } from 'native-base'; const NotificationsSettings = () => { const { settings, updateSettings } = useUserSettings(); diff --git a/front/views/settings/PreferencesSettings.tsx b/front/views/settings/PreferencesSettings.tsx index 4c9f12f..19593f1 100644 --- a/front/views/settings/PreferencesSettings.tsx +++ b/front/views/settings/PreferencesSettings.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useDispatch } from 'react-redux'; -import { Column, useTheme } from 'native-base'; +import { Column } from 'native-base'; import { useLanguage } from '../../state/LanguageSlice'; import { AvailableLanguages, DefaultLanguage, translate } from '../../i18n/i18n'; import { useSelector } from '../../state/Store'; @@ -13,7 +13,6 @@ const PreferencesSettings = () => { const dispatch = useDispatch(); const language = useSelector((state) => state.language.value); const settings = useSelector((state) => state.settings.local); - const { colors } = useTheme(); return ( diff --git a/front/views/settings/PrivacySettings.tsx b/front/views/settings/PrivacySettings.tsx index 715f14d..386c014 100644 --- a/front/views/settings/PrivacySettings.tsx +++ b/front/views/settings/PrivacySettings.tsx @@ -7,13 +7,11 @@ import { updateSettings } from '../../state/SettingsSlice'; import useUserSettings from '../../hooks/userSettings'; import { LoadingView } from '../../components/Loading'; import { Driver, Like1, Shop } from 'iconsax-react-native'; -import { useTheme } from 'native-base'; const PrivacySettings = () => { const dispatch = useDispatch(); const settings = useSelector((state: RootState) => state.settings.local); const { settings: userSettings, updateSettings: updateUserSettings } = useUserSettings(); - const { colors } = useTheme(); if (!userSettings.data) { return ; diff --git a/front/views/settings/SettingsProfile.tsx b/front/views/settings/SettingsProfile.tsx index ebb1c99..5873e22 100644 --- a/front/views/settings/SettingsProfile.tsx +++ b/front/views/settings/SettingsProfile.tsx @@ -1,6 +1,6 @@ import API from '../../API'; import React from 'react'; -import { Column, Toast, useTheme } from 'native-base'; +import { Column, Toast } from 'native-base'; import { LoadingView } from '../../components/Loading'; import ElementList from '../../components/GtkUI/ElementList'; import { translate } from '../../i18n/i18n'; @@ -10,7 +10,6 @@ import { Google, PasswordCheck, SmsEdit, UserSquare, Verify } from 'iconsax-reac import ChangeEmailForm from '../../components/forms/changeEmailForm'; import ChangePasswordForm from '../../components/forms/changePasswordForm'; import LogoutButtonCC from '../../components/UI/LogoutButtonCC'; -import useColorScheme from '../../hooks/colorScheme'; const handleChangeEmail = async (newEmail: string): Promise => { await API.updateUserEmail(newEmail); @@ -31,7 +30,7 @@ const ProfileSettings = () => { return ; } const user = userQuery.data; - const { colors } = useTheme(); + return (