Skip to content

Commit

Permalink
Merge pull request #2715 from metabrainz/tags-component
Browse files Browse the repository at this point in the history
LB-1410, LB-1340, LB-1337: Tags component: show all tags and improve layout
  • Loading branch information
MonkeyDo authored Jan 18, 2024
2 parents 0c3336d + 0d2b59a commit 908023d
Show file tree
Hide file tree
Showing 36 changed files with 265 additions and 129 deletions.
1 change: 0 additions & 1 deletion frontend/css/tags.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
height: 100%;
display: inline-block;
padding: 3px 7px;
vertical-align: middle;
&:first-child {
border-top-left-radius: @tagBorderRadius;
border-bottom-left-radius: @tagBorderRadius;
Expand Down
5 changes: 2 additions & 3 deletions frontend/js/src/entity-pages/AlbumPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ export default function AlbumPage(props: AlbumPageProps): JSX.Element {
);

const filteredTags = chain(releaseGroupTags)
.filter("genre_mbid")
.sortBy("count")
.value()
.reverse();
Expand Down Expand Up @@ -484,13 +483,13 @@ export default function AlbumPage(props: AlbumPageProps): JSX.Element {
);
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
5 changes: 2 additions & 3 deletions frontend/js/src/entity-pages/ArtistPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export default function ArtistPage(props: ArtistPageProps): JSX.Element {
popularRecordings.map(popularRecordingToListen) ?? [];

const filteredTags = chain(artist.tag?.artist)
.filter("genre_mbid")
.sortBy("count")
.value()
.reverse();
Expand Down Expand Up @@ -482,13 +481,13 @@ export default function ArtistPage(props: ArtistPageProps): JSX.Element {
);
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ function ExplorePage() {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, globalAppContext } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, globalAppContext } = await getPageProps();

const renderRoot = createRoot(domContainer!);
renderRoot.render(
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/ai-brainz/AIBrainz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ function AIBrainzComponent(props: AIBrainzComponentProps) {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, globalAppContext } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, globalAppContext } = await getPageProps();

const AIBrainzComponentWithAlertNotifications = withAlertNotifications(
AIBrainzComponent
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/art-creator/ArtCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ function ArtCreator() {

export default ArtCreator;

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, globalAppContext, sentryProps } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, globalAppContext, sentryProps } = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ export default function CoverArtComposite() {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer } = await getPageProps();

const renderRoot = createRoot(domContainer!);
renderRoot.render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export default function CoverArtComposite() {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer } = await getPageProps();

const renderRoot = createRoot(domContainer!);
renderRoot.render(
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/fresh-releases/FreshReleases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ export default function FreshReleases() {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, globalAppContext, sentryProps } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, globalAppContext, sentryProps } = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/huesound/ColorPlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ export default class ColorPlay extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, reactProps, globalAppContext } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, reactProps, globalAppContext } = await getPageProps();

const { user } = reactProps;

Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/explore/lb-radio/LBRadio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ function LBRadio(props: LBRadioProps) {
);
}

document.addEventListener("DOMContentLoaded", () => {
const { domContainer, reactProps, globalAppContext } = getPageProps();
document.addEventListener("DOMContentLoaded", async () => {
const { domContainer, reactProps, globalAppContext } = await getPageProps();

const { user, mode, prompt, token } = reactProps;
const renderRoot = createRoot(domContainer!);
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/home/Homepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { getPageProps } from "../utils/utils";
import Blog from "./Blog";
import ErrorBoundary from "../utils/ErrorBoundary";

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const domContainer = document.querySelector("#blogs");
const { globalAppContext, sentryProps } = getPageProps();
const { globalAppContext, sentryProps } = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/lastfm/LastFMImporter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,13 @@ export default class LastFmImporter extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
16 changes: 6 additions & 10 deletions frontend/js/src/metadata-viewer/MetadataViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ function getNowPlayingRecordingMBID(
}

function filterAndSortTags(tags?: EntityTag[]): EntityTag[] | undefined {
return tags
?.filter((tag) => {
return tag.genre_mbid;
})
.sort((a, b) => {
if (a.genre_mbid && !b.genre_mbid) {
return 1;
}
return b.count - a.count;
});
return tags?.sort((a, b) => {
if (a.genre_mbid && !b.genre_mbid) {
return 1;
}
return b.count - a.count;
});
}

export default function MetadataViewer(props: MetadataViewerProps) {
Expand Down
16 changes: 1 addition & 15 deletions frontend/js/src/metadata-viewer/MetadataViewerPageWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ document.addEventListener("DOMContentLoaded", async () => {
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand All @@ -131,20 +131,6 @@ document.addEventListener("DOMContentLoaded", async () => {

const { playing_now } = reactProps;

/** Fetch and save list of MusicBrainz genres on startup
* Not sure where this should end (list of genres sent by back-end instead?)
* but for now genres are only used on this page
*/
try {
const response = await fetch(
"https://musicbrainz.org/ws/2/genre/all?fmt=txt"
);
const genresList = await response.text();
globalAppContext.musicbrainzGenres = Array.from(genresList.split("\n"));
} catch (error) {
console.error(error);
}

const PlayingNowPageWithAlertNotifications = withAlertNotifications(
PlayingNowPage
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/missing-mb-data/MissingMBData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ export default class MissingMBDataPage extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/player-pages/PlayerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ export default class PlayerPage extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/playlists/Playlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ export default class PlaylistPage extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/playlists/Playlists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ export default class UserPlaylists extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/recent/RecentListens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ export default class RecentListens extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;
if (sentry_dsn) {
Sentry.init({
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/recommendations/Recommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ export default class Recommendations extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/recommendations/RecommendationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ export default class RecommendationsPage extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/stats/UserEntityChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,13 @@ export default class UserEntityChart extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/js/src/stats/UserReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ export default class UserReports extends React.Component<
}
}

document.addEventListener("DOMContentLoaded", () => {
document.addEventListener("DOMContentLoaded", async () => {
const {
domContainer,
reactProps,
globalAppContext,
sentryProps,
} = getPageProps();
} = await getPageProps();
const { sentry_dsn, sentry_traces_sample_rate } = sentryProps;

if (sentry_dsn) {
Expand Down
Loading

0 comments on commit 908023d

Please sign in to comment.