Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-12205: Add "play on ListenBrainz" button #2636

Merged
merged 1 commit into from
Dec 30, 2022

Conversation

reosarevok
Copy link
Member

@reosarevok reosarevok commented Sep 14, 2022

Implement MBS-12205

As requested, this mostly copies the functionality of the existing script (https://gist.github.com/MonkeyDo/6b919302e97dc979f8277b9c71ff82ab). It only shows on overview pages for collections and RGs, but that's also true of the script so hopefully not a problem. Ideally, LB would support passing an RG or collection MBID directly.

Examples:

Screenshot from 2022-10-17 19-33-23

Screenshot from 2022-10-17 19-32-35

@reosarevok reosarevok added the New feature Non urgent new stuff label Sep 14, 2022
@MonkeyDo
Copy link
Member

Yes, I do agree we should reconstruct a playlist based on a collection from the database directly.
Since this wasn't something I could do with the script I didn't go there, but it can certainly be improved upon.

I also think the tags and genres pages would be good candidates for a similar mechanism (reconstruct a playlist by fetching recordings with tag = x)

@reosarevok reosarevok requested a review from Aerozol October 17, 2022 16:28
@reosarevok
Copy link
Member Author

@Aerozol: if you have some time to look into this, I'd be grateful - I'm not super convinced by the position of the button on stuff without cover art (so, the recording example above, or even just releases/RGs without any art).

@Aerozol
Copy link
Contributor

Aerozol commented Oct 18, 2022

@reosarevok Hmm, the placement seems fine to me, if we really want to make it stand out (since nothing else gets such a big button, and right at the top!)
Only change is that I think we can remove the LB logo since we already say ‘Play on ListenBrainz’. A ‘play’ icon might be more tempting for people to click it:

image

Or even just go with the play button, since I don’t think where it gets played is much of a factor (until LB gets known). Just not sure about there being no signposting that it links to a new site:

image

@reosarevok
Copy link
Member Author

the placement seems fine to me, if we really want to make it stand out

Yeah, my worry was that it seemed a bit too overpowering :) But it might be fine.

@MonkeyDo
Copy link
Member

It is indeed a good question, do we want it to stand out that much?
I initially did it that way because, well, it was mostly for myself, but is there going to be community backlash?
I think aerozol's mockup with the more subdued button with no colorful logo would help in that respect.

Here's a couple of less prominent alternatives, not sure any of them have much merit but thought I'd try them out just to be exhaustive:

As a tab: (IMO that breaks what users expect of a tab)
image

Lower in the sidebar:
image

As text rather than a button:
image

Below the tracklist:
image

Same but to the right:
image

Floaty button on the right of the header (straight away no for this one)
image

[Pardon the french]

@Aerozol
Copy link
Contributor

Aerozol commented Oct 18, 2022

Ooh, so exhaustive!
Now my pick would be the bottom right below the tracklist, but with a play icon instead of the LB icon.

FYI I have addressed this in two possible ways in the redesign:

Top right
image

And when clicking on the album art column (so you can play any release from an artist page/table)
image

We could make a new type of button/something fancy here too but I think it’s a good idea to stick with the current button styles for the current site.

@reosarevok
Copy link
Member Author

Keep in mind this is also in recording, RG and some collection pages :) I guess whatever we pick should be consistent among those, ideally

@reosarevok reosarevok changed the base branch from master to production December 21, 2022 19:58
Comment on lines 177 to 178
// $FlowIssue (both incompatible-type and prop-missing, sigh)
? entities.map((entity: RecordingT) => entity.gid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the incompatible-type isn't really a Flow issue, since it has no way of knowing these are recordings. I'm not sure why it's giving prop-missing there, that does seem like a Flow issue. But I was able to work around both by casting the list to $ReadOnlyArray<CoreEntityT> first:

Suggested change
// $FlowIssue (both incompatible-type and prop-missing, sigh)
? entities.map((entity: RecordingT) => entity.gid)
? (entities: $ReadOnlyArray<CoreEntityT>).map(entity => entity.gid)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t mind either way for now because it’s just a global issue in MBS JS code.

Just as a side-note: CoreEntityT is overused in general. It is better than using any but still. This is one of the main issues I encountered while working on #2732 the 4 first commits of which are just about replacing a few unneeded CoreEntityTypeT occurrences. There are 300+ occurrences in the JS code, there are good chances that many of these are not fine-grained enough, later on generating the kind of Flow issue that you have here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it already knows that entities: $ReadOnlyArray<T> and T: CoreEntityT - as such, it should know these have gids. In any case, casting to CoreEntityT again seems like a hack. What would be ideal is for Flow to understand that if we know collectionEntityType is 'recording' then we also know that entities is $ReadOnlyArray<RecordingT>, but I'm guessing with the way we're doing this now, we can't just use the https://flow.org/en/docs/types/unions/#toc-disjoint-object-unions thing since hardcoding the collectionEntityType directly for all, but typing it as T['entityType']. I guess this might work better if the type was a proper union instead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yeah, I missed that props is a disjoint object union, so we could use that:

  const recordingMbids = props.collectionEntityType === 'recording' && props.entities.length > 0
    ? props.entities.map(entity => entity.gid)
    : null;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the type declaration a bit, but now it's happy (we can squash on merge as needed).

Copy link
Contributor

@yvanzo yvanzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code (typing apart) looks good 👍 but the commit message is very incomplete.

I did successfully test it locally 👍 using the production standby database and visiting some random pages as no example is given in PR’s description.

There is no request to ListenBrainz so no overhead 👍 however ListenBrainz might not be able to play it as user would expect it from the button’s label. Not a showstopper, just to be known and documented.

The placement is very nice 👍 as it clearly and very visibly promotes ListenBrainz without getting into the way.

The icon has not been changed despite @Aerozol’s comment. Probably not a showstopper either, it can be changed later on if there is some hurry about this ticket.

@yvanzo
Copy link
Contributor

yvanzo commented Dec 22, 2022

In reply to @Aerozol’s and @MonkeyDo’s comments on placement and community acceptance:

I don’t think that there could be any community backslash about it since the link is clearly labeled and put in the sidebar where prominent external links (including CritiqueBrainz) are expected. The current placement (prominently at the top just under the cover art) is very relevant as it is a top-notch MeB project. It seems to be a good balance. Good work!

However it’s always useful to communicate more about it with the community if you want this new feature to be noticed at the very least.

@reosarevok
Copy link
Member Author

Since the intent of the whole thing is, let's be honest, more promoting LB than giving a place to play music (both, but in that order), I think the logo probably makes sense? Although I'm fine with changing it to a play button if we prefer a bit later on :)

@reosarevok reosarevok force-pushed the MBS-12205 branch 2 times, most recently from 88f8ecf to 707bb45 Compare December 22, 2022 15:54
Copy link
Contributor

@yvanzo yvanzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having improved the commit message. 🚢

Please check with @bitmap about the Flow suggestion he made. Whether your change is enough or if it should be changed later on in master branch. (It doesn’t make a difference for now in production.)

@yvanzo
Copy link
Contributor

yvanzo commented Dec 22, 2022

In reply to @Aerozol about the icon:

As mentioned in a later discussion on #metabrainz, the added button is more about promoting LB than promising that it will play anything. So using the logo makes sense. The button’s label is a trick but I don’t have any better suggestion.

@yvanzo
Copy link
Contributor

yvanzo commented Dec 22, 2022

@brainzbot, please retest it.

@Aerozol
Copy link
Contributor

Aerozol commented Dec 24, 2022

@yvanzo re. promoting LB, the icon doesn’t invite people to click the button - the play button does, so I think that would ‘promote’ LB more.
Unless you already know the LB logo/colours the icon is not that helpful. I would consider taking it out completely tbh, that the button has ListenBrainz clearly on there which is pretty cool.
But none of this is a big issue, just digging into it : )

@reosarevok
Copy link
Member Author

@Aerozol I think I'd feel a bit bad making it a play button because I feel that would make it even more frustrating if they click and they cannot actually play anything :/

This mostly copies the functionality
of the existing script
(https://gist.github.com/MonkeyDo/6b919302e97dc979f8277b9c71ff82ab).
It shows a "Play on ListenBrainz" button on the right side of releases,
recordings, recording collections and release groups that sends
the user to play the release or a custom grouping of recordings
with BrainzPlayer.
It only shows on overview pages for recording collections and RGs,
but that's also true of the script so hopefully not a problem.
Ideally, LB would support passing an RG or collection MBID directly.

Keep in mind this doesn't hit LB and doesn't know whether LB can
actually play the music (I'm not sure even hitting LB would help
since LB might also not know until it tries).
@Aerozol
Copy link
Contributor

Aerozol commented Dec 28, 2022

@reosarevok but… it says ‘Play on ListenBrainz’?
But mainly, generally speaking I’m not a fan of adding extra bits in unless it’s justified/there’s a reason, and I’m not sure the LB icon meets that criteria.

Regardless thanks for putting this in, great feature!

@reosarevok
Copy link
Member Author

I know, I know. But having the play icon and the word Play seems like it's stronger? Dunno. We can change it in January if you prefer, no worries :) (although to be fair, the play button is also new for MB itself :) )

@reosarevok reosarevok merged commit f2e635d into metabrainz:production Dec 30, 2022
@reosarevok reosarevok deleted the MBS-12205 branch December 30, 2022 10:41
@yvanzo
Copy link
Contributor

yvanzo commented Dec 30, 2022

@Aerozol wrote:

But mainly, generally speaking I’m not a fan of adding extra bits in unless it’s justified/there’s a reason, and I’m not sure the LB icon meets that criteria.

ListenBrainz's icon is added just like other external websites' icons have been added before.
Maybe it should be placed under external-favicons/ instead of icons/ to make it more explicit?

@Aerozol wrote:

@reosarevok but… it says ‘Play on ListenBrainz’?

As mentioned in a previous comment which links to IRC, this button is more about promoting ListenBrainz than necessarily playing something. We can come with a more accurate (but still incentive) label such as “Check it out on ListenBrainz”. ListenBrainz should also more gracefully handle when it fails at playing anything.

@Aerozol
Copy link
Contributor

Aerozol commented Jan 1, 2023

@yvanzo The button format is quite different to the format of the other external links - can you explain why it’s helpful to have the LB icon there? Personally I don’t think more noise and imagery makes it easier for people to navigate/understand our already-messy sidebar.

I wouldn’t change the name from ‘Play on ListenBrainz’, that’s currently the primary function even if it doesn’t always work.
Edit: Instead of primary function I should have said ‘call to action’. I can’t think of any other reason why somebody would go to LB from MB. Being able to play the song (or try to) is a massive new function!

mwiencek added a commit that referenced this pull request Jan 9, 2023
* production:
  Block :// in usernames
  MBS-12827: Run our sanitize function on new usernames
  Fix building CSS in production Docker images (#2623)
  MBS-12205: Add "play on ListenBrainz" button (#2636)
mwiencek added a commit that referenced this pull request Jan 9, 2023
* beta:
  Block :// in usernames
  MBS-12827: Run our sanitize function on new usernames
  MBS-12693: Select relationship type before target (#2800)
  MBS-12709: Do not copy series part number with "Add another [entity]" (#2798)
  MBS-12820: Add default label for attribute multiselects (#2799)
  MBS-12809: Pass minimal existing data for Historic/RemoveDiscID (#2792)
  MBS-12817: Fix selector for relationship dialog warnings (#2795)
  MBS-12787: Editing a relationship to add instruments causes duplication (#2797)
  MBS-12737: Properly check backwardness with isRelationshipBackward (#2796)
  Fix building CSS in production Docker images (#2623)
  Update POT files using the production database
  Update translations from Transifex
  MBS-12205: Add "play on ListenBrainz" button
  MBS-12205: Add "play on ListenBrainz" button (#2636)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Non urgent new stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants