From 2c9ec4a7d39264b63e96575912817539583e17d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 5 Dec 2023 11:24:15 +0100 Subject: [PATCH] added missing useAssets in Scaffold and did duplicate suppresion for play history --- front/components/UI/ScaffoldCC.tsx | 10 ++++++---- front/components/UI/ScaffoldDesktopCC.tsx | 16 +++++++++++++++- front/views/PlayView.tsx | 1 - 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/front/components/UI/ScaffoldCC.tsx b/front/components/UI/ScaffoldCC.tsx index c6070a0..f49dfc7 100644 --- a/front/components/UI/ScaffoldCC.tsx +++ b/front/components/UI/ScaffoldCC.tsx @@ -7,6 +7,7 @@ import { Cup, Discover, Music, SearchNormal1, Setting2, User } from 'iconsax-rea import { LoadingView } from '../Loading'; import ScaffoldDesktopCC from './ScaffoldDesktopCC'; import ScaffoldMobileCC from './ScaffoldMobileCC'; +import { useAssets } from 'expo-asset'; const menu = [ { type: 'main', title: 'menuDiscovery', icon: Discover, link: 'HomeNew' }, @@ -37,10 +38,11 @@ const ScaffoldCC = ({ return ; } const colorScheme = useColorScheme(); - const logo = + const [logo] = useAssets( colorScheme == 'light' ? require('../../assets/icon_light.png') - : require('../../assets/icon_dark.png'); + : require('../../assets/icon_dark.png') + ); return ( @@ -48,7 +50,7 @@ const ScaffoldCC = ({ { return ; } - const musics = history.data.map((h) => h.song)?.slice(0, props.quantity); + const musics = history.data + .reduce( + (acc, curr) => { + if (acc.length === 0) { + return [curr]; + } + if (acc.find((h) => h.song.id === curr.song.id)) { + return acc; + } + return [...acc, curr]; + }, + [] as typeof history.data + ) + .map((h) => h.song) + ?.slice(0, props.quantity); return ( diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index eb3f2cc..8ccfb46 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -472,7 +472,6 @@ const PlayView = ({ songId, route }: RouteProps) => { score={score} time={time} paused={paused} - disabled={!midiKeyboardFound} song={song.data} onEnd={onEnd} onPause={onPause}