Skip to content

Commit

Permalink
fix: slow playlists rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed Oct 10, 2023
1 parent 84d2c39 commit ee0bfbf
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/components/playlists/Playlists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,28 @@ export default () => {
</Pressable>
);

const renderItem = ({
item,
drag,
isActive,
}: RenderItemParams<NoxMedia.Playlist>) => {
const renderItem = ({ item, drag, isActive }: RenderItemParams<string>) => {
const playlist = playlists[item];
return (
<ScaleDecorator>
<TouchableRipple
onLongPress={drag}
disabled={isActive}
onPress={() => goToPlaylist(item.id)}
onPress={() => goToPlaylist(item)}
style={[
{
backgroundColor:
currentPlaylist.id === item?.id
currentPlaylist.id === item
? playerStyle.customColors.playlistDrawerBackgroundColor
: undefined,
},
]}
>
<PlaylistItem
item={item}
item={playlist}
confirmOnDelete={confirmOnDelete}
leadColor={
currentPlayingList.id === item?.id
currentPlayingList.id === item
? playerStyle.colors.primary //customColors.playlistDrawerBackgroundColor
: undefined
}
Expand Down Expand Up @@ -157,11 +154,9 @@ export default () => {
<View style={{ flex: 1 }}>
<DraggableFlatList
style={[styles.draggableFlatList]}
data={playlistIds.map(val => playlists[val])}
onDragEnd={({ data }) =>
setPlaylistIds(data.map(playlist => playlist.id))
}
keyExtractor={item => item?.id}
data={playlistIds}
onDragEnd={({ data }) => setPlaylistIds(data)}
keyExtractor={item => item}
renderItem={renderItem}
/>
</View>
Expand Down

0 comments on commit ee0bfbf

Please sign in to comment.