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

Add album year to the list & the details view #391

Merged
merged 9 commits into from
Dec 9, 2021

Conversation

sei0o
Copy link
Contributor

@sei0o sei0o commented Dec 2, 2021

Fixes #137

It looks like this:
image

and at the details view:
image

The GTK part wasn't that hard, but the problem is that not only albums but also playlists makes use of Album through TrackItem. The album widget requires AlbumModel , AlbumModel requires AlbumDescription, and AlbumDescription requires Album.

I tried moving release_date in AlbumReleaseDetails to AlbumDescription (in commit dc71a29) and it worked fine for albums. However, since playlists do not have their release dates, the program fails to parse them. I could just let release_date stay in AlbumReleaseDetails and use it, but in SearchResults::update_results, for example, we do not have access to an AlbumReleaseDetails.

The commits are messed up... I will squash them later.

@sei0o sei0o marked this pull request as draft December 2, 2021 14:53
@xou816
Copy link
Owner

xou816 commented Dec 5, 2021

Hey, thanks a lot for your work! :) this looks promising!

but also playlists makes use of Album through TrackItem.

Yeah, sorry about that :( I'm absolutely open to this being changed though! Two possibilities off the top of my head: either we keep going with this model being shared but adapt the widget so that things such as the release date are Options, or break it into two distinct widget+model pairs. What do you think?

As for search results or playlists, well if we don't have the date, don't sweat it, we won't be able to show it and it is fine. This too could be solved by having the release date be an Option in that AlbumModel I think!

@sei0o sei0o marked this pull request as ready for review December 6, 2021 14:49
@sei0o
Copy link
Contributor Author

sei0o commented Dec 6, 2021

Thanks for the advice! Now I have wrapped release_date in some structs with Option. I was also thinking about the same idea as your second option, but for now this solution would be enough. Sorry for many force-pushes, mistakenly believed I was merging to master 😅

@@ -35,11 +35,15 @@ leaflet.folded .album .album__cover {
font-size: 14px;
}

.album label.album__year {
font-size: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

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

We really shouldn't hardcode font-sizes like that. Not a blocker for this particular PR since it's used elsewhere, but eventually, we need to remove these.

Copy link
Contributor Author

@sei0o sei0o Dec 7, 2021

Choose a reason for hiding this comment

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

Agreed. GTK offers @define-color to reduce hard-coded colors, but it doesn't for other types. Neither var() seems to be unavailable for GTK so without preprocessors would that be difficult?

Copy link
Contributor

Choose a reason for hiding this comment

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

rem seems to do the trick:
image

@@ -85,6 +98,7 @@ mod imp {
Self {
album: RefCell::new(None),
artist: RefCell::new(None),
year: RefCell::new(0),
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like this could definitely be a RefCell<Option>, this would avoid all the unwrapping and awkward comparison to 0 you have to deal with!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was still confused how GTK deals with optional values. Fixed in the latest commit. :)

Copy link
Owner

@xou816 xou816 left a comment

Choose a reason for hiding this comment

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

looks good to me for the most part, again thanks!! :)

Copy link
Owner

@xou816 xou816 left a comment

Choose a reason for hiding this comment

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

almost there!

src/app/models/main.rs Outdated Show resolved Hide resolved
src/app/models/main.rs Show resolved Hide resolved
src/app/models/gtypes/album_model.rs Show resolved Hide resolved
src/app/models/gtypes/album_model.rs Show resolved Hide resolved
src/app/components/album/album.rs Show resolved Hide resolved
@xou816
Copy link
Owner

xou816 commented Dec 9, 2021

All good to me :) looks like you've got a few conflicts to fix but then we're good to merge!

@sei0o
Copy link
Contributor Author

sei0o commented Dec 9, 2021

Resolved conflicts :)

@xou816
Copy link
Owner

xou816 commented Dec 9, 2021

Perfect, great work, merging this. thanks!

@xou816 xou816 merged commit b3a7827 into xou816:development Dec 9, 2021
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.

Add album year to the album list
3 participants