feat: show total LB play count on artist detail page
Added GetArtistPlayCount(mbid) — fetches ArtistPopularity from LB for a single MBID and returns the total listen count. Fire-and-forget call on the artist page, displays below the meta line as '1.3M plays on ListenBrainz' (uses existing formatListenCount).
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
TopReleaseGroupsForArtist,
|
||||
SimilarArtists,
|
||||
GetArtistImageURL,
|
||||
GetArtistPlayCount,
|
||||
CheckLibraryMBIDs,
|
||||
} from '@go/explore/Service';
|
||||
import type {
|
||||
@@ -99,6 +100,7 @@ export class ExploreArtistDetails extends LitElement {
|
||||
@state() private artistImageURL = '';
|
||||
@state() private similarImageURLs = new Map<string, string>();
|
||||
@state() private topSectionExpanded = false;
|
||||
@state() private artistPlayCount = 0;
|
||||
private libraryMBIDs = new Set<string>();
|
||||
|
||||
/* ── Styles ── */
|
||||
@@ -669,6 +671,9 @@ export class ExploreArtistDetails extends LitElement {
|
||||
this.fetchArtistImage(mbid);
|
||||
}
|
||||
|
||||
// Play count is fire-and-forget.
|
||||
this.fetchArtistPlayCount(mbid);
|
||||
|
||||
// Check which release groups are in the local library.
|
||||
this.checkLibrary();
|
||||
|
||||
@@ -834,6 +839,17 @@ export class ExploreArtistDetails extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchArtistPlayCount(mbid: string) {
|
||||
try {
|
||||
const count = await GetArtistPlayCount(mbid);
|
||||
if (count > 0) {
|
||||
this.artistPlayCount = count;
|
||||
}
|
||||
} catch {
|
||||
// Non-critical.
|
||||
}
|
||||
}
|
||||
|
||||
private async checkLibrary() {
|
||||
const mbids: string[] = [];
|
||||
|
||||
@@ -1026,6 +1042,9 @@ export class ExploreArtistDetails extends LitElement {
|
||||
? html`<div class="artist-native-name">${this.artist.name}</div>`
|
||||
: nothing}
|
||||
${this.renderArtistMeta()}
|
||||
${this.artistPlayCount > 0
|
||||
? html`<span class="artist-meta">${formatListenCount(this.artistPlayCount)} plays on ListenBrainz</span>`
|
||||
: nothing}
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
|
||||
Reference in New Issue
Block a user