Truncate the displayed pin blurb after 280 characters This is the maximum allowed by the LB UI. This makes sure and overly long blurb does not break the layout. The full blurb is available as title attribute tooltip.
2 files changed, 13 insertions(+), 1 deletions(-) M assets/javascripts/discourse/components/listenbrainz-listening.js M assets/javascripts/discourse/templates/components/listenbrainz-listening.hbs
M assets/javascripts/discourse/components/listenbrainz-listening.js => assets/javascripts/discourse/components/listenbrainz-listening.js +12 -0
@@ 3,6 3,10 @@ import { tracked } from '@glimmer/tracking' import { ajax } from 'discourse/lib/ajax' import { buildMbUrl } from '../lib/listenbrainz-utils' // 280 characters is the maximum length of the blurb allowed by ListenBrainz UI. // But it might be longer if created by API. const maxBlurbLength = 280 export default class ListeningComponent extends Component { @@ constructor(owner, args) { 142,6 146,14 @@ export default class ListeningComponent extends Component { return this.listen?.blurb_content } get truncatedBlurb() { let blurb = (this.blurb || '').trim() if (blurb.length > maxBlurbLength) { blurb = blurb.substring(0, maxBlurbLength - 1) + '…' } return blurb } async loadNowPlaying() { this.loading = true try {
M assets/javascripts/discourse/templates/components/listenbrainz-listening.hbs => assets/javascripts/discourse/templates/components/listenbrainz-listening.hbs +1 -1