added missing useAssets in Scaffold and did duplicate suppresion for play history

This commit is contained in:
Clément Le Bihan
2023-12-05 11:24:15 +01:00
parent 393782b4b8
commit 2c9ec4a7d3
3 changed files with 21 additions and 6 deletions
+6 -4
View File
@@ -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 <LoadingView />;
}
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 (
<Flex style={{ flex: 1, backgroundColor: '#cdd4fd' }}>
@@ -48,7 +50,7 @@ const ScaffoldCC = ({
<ScaffoldMobileCC
enableScroll={enableScroll}
user={userQuery.data}
logo={logo}
logo={logo?.at(0)?.uri ?? ''}
routeName={routeName}
menu={menu}
widthPadding={withPadding}
@@ -58,7 +60,7 @@ const ScaffoldCC = ({
) : (
<ScaffoldDesktopCC
user={userQuery.data}
logo={logo}
logo={logo?.at(0)?.uri ?? ''}
routeName={routeName}
menu={menu}
widthPadding={withPadding}
+15 -1
View File
@@ -36,7 +36,21 @@ const SongHistory = (props: { quantity: number }) => {
return <LoadingView />;
}
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 (
<View>