Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LB-1698: Switching between different stat timeframes can sometimes break the stats displayed #3065

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions frontend/js/src/user/stats/components/UserTopEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Loader from "../../../components/Loader";
import { getChartEntityDetails, userChartEntityToListen } from "../utils";
import ListenCard from "../../../common/listens/ListenCard";
import GlobalAppContext from "../../../utils/GlobalAppContext";
import { getListenCardKey } from "../../../utils/utils";

export type UserTopEntityProps = {
range?: UserStatsAPIRange;
Expand Down Expand Up @@ -101,11 +102,12 @@ export default function UserTopEntity(props: UserTopEntityProps) {
count: artist.listen_count,
};
const listenDetails = getChartEntityDetails(interchangeFormat);
const listen = userChartEntityToListen(interchangeFormat);
return (
<ListenCard
key={artist.artist_mbid}
key={`top-artist-${getListenCardKey(listen)}`}
listenDetails={listenDetails}
listen={userChartEntityToListen(interchangeFormat)}
listen={listen}
showTimestamp={false}
showUsername={false}
additionalActions={
Expand Down Expand Up @@ -145,11 +147,12 @@ export default function UserTopEntity(props: UserTopEntityProps) {
artists: release.artists,
};
const listenDetails = getChartEntityDetails(interchangeFormat);
const listen = userChartEntityToListen(interchangeFormat);
return (
<ListenCard
key={release.release_mbid}
key={`top-release-${getListenCardKey(listen)}`}
listenDetails={listenDetails}
listen={userChartEntityToListen(interchangeFormat)}
listen={listen}
showTimestamp={false}
showUsername={false}
additionalActions={
Expand Down Expand Up @@ -201,7 +204,9 @@ export default function UserTopEntity(props: UserTopEntityProps) {
};
return (
<ListenCard
key={recording_mbid}
key={`top-recording-${getListenCardKey(
listenFromRecording
)}`}
listen={listenFromRecording}
showTimestamp={false}
showUsername={false}
Expand Down Expand Up @@ -234,11 +239,12 @@ export default function UserTopEntity(props: UserTopEntityProps) {
artists: releaseGroup.artists,
};
const listenDetails = getChartEntityDetails(interchangeFormat);
const listen = userChartEntityToListen(interchangeFormat);
return (
<ListenCard
key={releaseGroup.release_group_mbid}
key={`top-release-group-${getListenCardKey(listen)}`}
listenDetails={listenDetails}
listen={userChartEntityToListen(interchangeFormat)}
listen={listen}
showTimestamp={false}
showUsername={false}
additionalActions={
Expand Down
Loading