~phw/discourse-listenbrainz

0d8ada9b992434e6b382b122e13beb7ff4c422c2 — Philipp Wolfer 9 months ago 13829d0
Fix profile cover collage not showing
M assets/javascripts/discourse/components/listenbrainz-profile.js => assets/javascripts/discourse/components/listenbrainz-profile.js +4 -0
@@ 40,6 40,10 @@ export default class ProfileComponent extends Component {
        }))
    }

    get coverUrl() {
        return this.profile?.thumbnail_url
    }

    async loadProfile() {
        this.loading = true
        try {

M assets/javascripts/discourse/templates/components/listenbrainz-cover-collage.hbs => assets/javascripts/discourse/templates/components/listenbrainz-cover-collage.hbs +1 -1
@@ 1,5 1,5 @@
{{#if this.showCover}}
<object data="{{this.showCover}}"
<object data="{{this.src}}"
    type="image/svg+xml"
    title="{{this.title}}"
    {{on "load" this.onLoad}}

M assets/javascripts/discourse/templates/components/listenbrainz-listening.hbs => assets/javascripts/discourse/templates/components/listenbrainz-listening.hbs +3 -1
@@ 6,8 6,10 @@
            <a href="{{releaseUrl}}" title="{{album}}" target="_blank">
                {{listenbrainz-cover src=coverUrl}}
            </a>
            {{else}}
            {{else if coverUrl}}
                {{listenbrainz-cover src=coverUrl title=album}}
            {{else}}
            <span/>
            {{/if}}
        </div>
        <div class="listenbrainz-card-details">

M assets/javascripts/discourse/templates/components/listenbrainz-profile.hbs => assets/javascripts/discourse/templates/components/listenbrainz-profile.hbs +5 -1
@@ 2,11 2,15 @@
<div class="listenbrainz-card listenbrainz-user-profile">
    <div class="listenbrainz-card-main-content">
        <div class="listenbrainz-card-thumbnail">
            {{#if coverUrl}}
            <a href="https://listenbrainz.org/user/{{profile.username}}"
                target="_blank"
                title="{{profile.username}}">
                {{listenbrainz-cover-collage src=profile.thumbnail_url}}
                {{listenbrainz-cover-collage src=coverUrl}}
            </a>
            {{else}}
            <span/>
            {{/if}}
        </div>
        <div class="listenbrainz-card-details">
            {{#if loading }}

M test/javascripts/acceptance/listenbrainz-profile-card-test.js => test/javascripts/acceptance/listenbrainz-profile-card-test.js +17 -6
@@ 79,19 79,30 @@ acceptance('ListenBrainz - User Summary - Profile Card', needs => {
        const recordingCreditLinks = queryAll('.listenbrainz-card-secondary a')
        assert.equal(
            recordingCreditLinks[0].href,
            'https://musicbrainz.org/recording/52bdc800-67bb-4c2c-987d-880485bc73e3')
        assert.equal(recordingCreditLinks[0].innerText, 'Spirits That I Called')
            'https://musicbrainz.org/recording/52bdc800-67bb-4c2c-987d-880485bc73e3',
            'it links the recording'
        )
        assert.equal(
            recordingCreditLinks[0].innerText,
            'Spirits That I Called',
            'it shows the recording title'
        )
        assert.equal(
            recordingCreditLinks[1].href,
            'https://musicbrainz.org/artist/8f4cf6d8-8979-4396-8fd9-505c29d5dbbb')
        assert.equal(recordingCreditLinks[1].innerText, 'Wisborg')
            'https://musicbrainz.org/artist/8f4cf6d8-8979-4396-8fd9-505c29d5dbbb',
            'it links the artist credits'
        )
        assert.equal(
            recordingCreditLinks[1].innerText, 'Wisborg',
            'it shows the artist credits name'
        )
        assert.equal(
            query('.listenbrainz-card-thumbnail object').data,
            query('.listenbrainz-card-thumbnail object')?.data,
            'https://api.listenbrainz.org/1/art/grid-stats/outsidecontext/this_year/2/0/132',
            'it shows the user cover art collage SVG'
        )
        assert.equal(
            query('.listenbrainz-card-thumbnail a').href,
            query('.listenbrainz-card-thumbnail a')?.href,
            'https://listenbrainz.org/user/outsidecontext',
            'it links the cover art collage to LB profile page'
        )