Do not write all the artists in case no album artist is found. ref #154

This commit is contained in:
emeric
2021-05-19 23:49:55 +02:00
parent 8338e88a26
commit 277df96bed
3 changed files with 32 additions and 19 deletions
+1
View File
@@ -15,6 +15,7 @@
<div class="Lms-header">
<h3><div class="Lms-releasename text-primary">${name}</div></h3>
${<if-has-release-artists>}${artists}${</if-has-release-artists>}
${<if-has-various-release-artists>}<div class="Lms-artistname text-muted">${tr:Lms.Explore.various-artists}</div>${</if-has-various-release-artists>}
<div class="text-muted"><small>${<if-has-year>}${year}${</if-has-year>}${<if-has-orig-year>} (${orig-year})${</if-has-orig-year>}</small></div>
${clusters}
${play-btn class="Lms-explore-btn Lms-btn"}${more-btn class="Lms-explore-btn Lms-btn"}
+30 -19
View File
@@ -107,25 +107,7 @@ Release::refreshView()
}
}
{
std::vector<Wt::Dbo::ptr<Database::Artist>> artists;
artists = release->getReleaseArtists();
if (artists.empty())
artists = release->getArtists();
if (!artists.empty())
{
setCondition("if-has-release-artists", true);
Wt::WContainerWidget* artistsContainer {bindNew<Wt::WContainerWidget>("artists")};
for (const auto& artist : artists)
{
Wt::WTemplate* artistTemplate {artistsContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template.entry-release-artist"))};
artistTemplate->bindWidget("artist", LmsApplication::createArtistAnchor(artist));
}
}
}
refreshReleaseArtists(release);
{
Wt::WImage* cover {bindNew<Wt::WImage>("cover", Wt::WLink(LmsApp->getCoverResource()->getReleaseUrl(release.id(), CoverResource::Size::Large)))};
@@ -263,6 +245,35 @@ Release::refreshView()
}
}
void
Release::refreshReleaseArtists(const Database::Release::pointer& release)
{
std::vector<Wt::Dbo::ptr<Database::Artist>> artists;
artists = release->getReleaseArtists();
if (artists.empty())
{
artists = release->getArtists(Database::TrackArtistLinkType::Artist);
if (artists.size() > 1)
{
setCondition("if-has-various-release-artists", true);
return;
}
}
if (!artists.empty())
{
setCondition("if-has-release-artists", true);
Wt::WContainerWidget* artistsContainer {bindNew<Wt::WContainerWidget>("artists")};
for (const auto& artist : artists)
{
Wt::WTemplate* artistTemplate {artistsContainer->addNew<Wt::WTemplate>(Wt::WString::tr("Lms.Explore.Release.template.entry-release-artist"))};
artistTemplate->bindWidget("artist", LmsApplication::createArtistAnchor(artist));
}
}
}
void
Release::refreshCopyright(const Database::Release::pointer& release)
{
+1
View File
@@ -44,6 +44,7 @@ namespace UserInterface
private:
void refreshView();
void refreshReleaseArtists(const Wt::Dbo::ptr<Database::Release>& release);
void refreshCopyright(const Wt::Dbo::ptr<Database::Release>& release);
void refreshLinks(const Wt::Dbo::ptr<Database::Release>& release);
void refreshSimilarReleases(const std::unordered_set<Database::IdType>& similarReleasesId);