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

Album info #268

Merged
merged 74 commits into from Aug 17, 2021
Merged

Album info #268

merged 74 commits into from Aug 17, 2021

Conversation

TotalDarkness-NRF
Copy link
Contributor

@TotalDarkness-NRF TotalDarkness-NRF commented Aug 7, 2021

This pull request focuses on adding a button and ui to albums to display some album info.

  • Added a button in albums to go to the info screen
  • Added a ui to display the info for albums

The layout is as follows:
image

@TotalDarkness-NRF
Copy link
Contributor Author

You'll also have to regenerate the potfiles: https://github.com/xou816/spot#regenerating-potfiles

Alright. will do. Also I thought this only applied to when I would change the potfiles

@xou816
Copy link
Owner

xou816 commented Aug 15, 2021

I'll have a proper look/review ASAP, thank you!!!

@@ -35,6 +35,8 @@ pub trait SpotifyApiClient {

fn get_album(&self, id: &str) -> BoxFuture<SpotifyResult<AlbumDescription>>;

fn get_album_info(&self, id: &str) -> BoxFuture<SpotifyResult<AlbumDescriptionInfo>>;
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry, I should have been clearer; I stand by what I said earlier, there is no need to duplicate the endpoint here; there is no reason get_album and get_album_info would return different things

What I meant when I said that you could have multiple API models was that other models that depend on Album could depend on a different model, for instance (model names are just an example):

  • RawSearchResults could have a Option<Page> because we don't get copyrights, label, etc
  • the regular endpoint would return a FullAlbum
    And then those two would be converted to our local model (AlbumDescription) or another one

@@ -96,6 +100,35 @@ impl PartialEq for AlbumDescription {

impl Eq for AlbumDescription {}

#[derive(Clone, Debug)]
pub struct AlbumDescriptionInfo {
Copy link
Owner

Choose a reason for hiding this comment

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

good idea to compose :)

naming suggestion: AlbumFullDescription ?

}

#[derive(Clone, Debug)]
pub struct AlbumInfoRef {
Copy link
Owner

Choose a reason for hiding this comment

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

a note on naming: those models I suffixed with Ref where meant to act like a "reference" to some resource; for instance ArtistRef would hold an identifier that would allow having a full Artist struct, and a name to help display that reference

In that case, maybe AlbumReleaseDetails?

pub struct AlbumInfoRef {
pub label: String,
pub release_date: String,
pub copyrights: Vec<CopyrightRef>,
Copy link
Owner

Choose a reason for hiding this comment

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

(same kind of comment)

Ok(album)
let info = self
.cache_get_or_write(SpotCacheKey::Album(&id), None, |etag| {
self.client.get_album_info(&id).etag(etag).send()
Copy link
Owner

Choose a reason for hiding this comment

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

Almost there :)

See the issue here is that we end up calling two times the same album endpoint within this function -- it's alright because of the cache but it should not happen regardless (actually not fine, it writes two different models to the same cache entry but anyway)

Ask yourself, what does the v1/album endpoint actually return? a "full" album as defined by Spotify, so the union of your current AlbumInfo + the previous Album model

Just update the get_album fn from the client to return the full API model, and then you're good I think, this line is no longer needed :) nor is get_album_info needed

#[derive(Clone, Debug)]
pub struct AlbumFullDescription {
pub description: AlbumDescription,
pub info: AlbumReleaseDetails,
Copy link
Owner

Choose a reason for hiding this comment

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

(nitpick: this field could be named release_details)

@xou816
Copy link
Owner

xou816 commented Aug 17, 2021

Thank you!! Looks like we're done :) I'll give it a quick final test to see if nothing broke after all the changes from review but it should be good to merge

@xou816 xou816 merged commit 5870cc4 into xou816:master Aug 17, 2021
@ondras12345
Copy link
Contributor

Hi,
It looks like there's something wrong with the positioning of the dialog window.
When I open some album's info and try moving the main Spot window by dragging it's titlebar, the dialog window jumps to the right edge of my rightmost monitor.
The interesting thing is that when I hold down Super while moving the main window, everything seems to work just fine.
Spot-album-info-move

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

GNOME 3.36.8

Do you want me to create an issue for this?

@xou816
Copy link
Owner

xou816 commented Aug 18, 2021

Hi! Yes, an issue will be easier to track, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants