From b479b7b6d3f5760aa7d2a10cefb327a89bb6fdb7 Mon Sep 17 00:00:00 2001 From: Andrew Mendelsohn Date: Wed, 24 Jan 2024 14:13:09 -0800 Subject: [PATCH] [QA-733] Dedupe albums and playlists on profile (#7316) --- packages/common/src/store/pages/profile/selectors.ts | 6 ++++-- packages/web/src/pages/profile-page/ProfilePageProvider.tsx | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/common/src/store/pages/profile/selectors.ts b/packages/common/src/store/pages/profile/selectors.ts index 632edb4f4e3..802ed29fb56 100644 --- a/packages/common/src/store/pages/profile/selectors.ts +++ b/packages/common/src/store/pages/profile/selectors.ts @@ -1,3 +1,5 @@ +import { uniq } from 'lodash' + import { getCollections } from 'store/cache/collections/selectors' import { getUser, getUsers } from 'store/cache/users/selectors' import type { CommonState } from 'store/commonStore' @@ -104,12 +106,12 @@ export const getProfileCollections = createDeepEqualSelector( export const getProfileAlbums = createDeepEqualSelector( [getProfileCollections], - (collections) => collections?.filter(({ is_album }) => is_album) + (collections) => uniq(collections?.filter(({ is_album }) => is_album)) ) export const getProfilePlaylists = createDeepEqualSelector( [getProfileCollections], - (collections) => collections?.filter(({ is_album }) => !is_album) + (collections) => uniq(collections?.filter(({ is_album }) => !is_album)) ) const sortByDateDesc = (a: Collection, b: Collection) => diff --git a/packages/web/src/pages/profile-page/ProfilePageProvider.tsx b/packages/web/src/pages/profile-page/ProfilePageProvider.tsx index 554785e04d6..5ea21c5cc8f 100644 --- a/packages/web/src/pages/profile-page/ProfilePageProvider.tsx +++ b/packages/web/src/pages/profile-page/ProfilePageProvider.tsx @@ -42,6 +42,7 @@ import { } from '@audius/common' import { push as pushRoute, replace } from 'connected-react-router' import { UnregisterCallback } from 'history' +import { uniq } from 'lodash' import moment from 'moment' import { connect } from 'react-redux' import { withRouter, RouteComponentProps } from 'react-router-dom' @@ -904,8 +905,8 @@ class ProfilePage extends PureComponent { profile, status: profileLoadingStatus, - albums, - playlists, + albums: uniq(albums), + playlists: uniq(playlists), artistTracks, playArtistTrack, pauseArtistTrack,