Skip to content

Conversation

@secondlnl
Copy link
Contributor

Ehm, so I tried something.

This is not how to do it, I feel.

Context: Trying to add a user view.

Will fix: #616

Samuel Oldham and others added 3 commits June 17, 2025 23:24
This makes the height of the description consistent with the artist image (in most cases). It also removes the redundant strings on the stats number and hides any stats if they are non-existent.

---------

Co-authored-by: Samuel Oldham <so9010>
Copied some of artist into user, changing some.

This is not how to do it I feel.
@jacksongoode
Copy link
Collaborator

jacksongoode commented Jun 18, 2025

Wooho! With new visual sections and UI it's great if you add a small screenshot/cap of the UI or screen state so we can better review.

@secondlnl
Copy link
Contributor Author

secondlnl commented Jun 18, 2025

Ok yeah, so would adding a new page actually work 😆
Sorry for seemingly just asking questions.

@secondlnl
Copy link
Contributor Author

NOTE: Copy-pasted thing and made it compile

@jacksongoode
Copy link
Collaborator

No rush, but when you get a chance, posting a screenshot of an example profile in the UI would be great!

@secondlnl
Copy link
Contributor Author

Still warnings and nothing to show for it.

@SO9010
Copy link
Collaborator

SO9010 commented Jun 26, 2025

Just to let you know you can use 'cargo clippy --fix --allow-dirty' to remove many of the warnings which you are encountering it is best if you run it regularly. If you use vscode you can set it to format on save which is honestly a god send imo!

Also if you feel as though you want any help do let me know and you can let me know what you are doing and trying to achieve.

I had a small look through your code so far and I thought to provide some feedback, i think you are trying to do too much at once as you have copy pasted the code from the album view and i assume you are trying to then change bits till it works, which will work but may get confusing and frustrating. What my advice would be is to start small.

Just start with displaying the users name and images as that is already part of public users, from this you can then understand better how druid handles new pages. Now that #631 has been merged, rebase your fork with that and then it will make approaching this a lot easier. You can make it so that this is clickable and that is what opens the page for now.

What I would also like to note is that you make want to also have a look at adding to the api here.

To get user profiles you will need to perform a call to:
https://spclient.wg.spotify.com/user-profile-view/v3/profile/michaeljesse?playlist_limit=10&artist_limit=10&episode_limit=10&market=from_token

which returns roughly this :

uri	"spotify:user:michaeljesse"
name	"Jesse"
image_url	"https://i.scdn.co/image/ab6775700000ee85570a918100ec80b9479c46f7"
followers_count	12
following_count	11
public_playlists	(10)[ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…} ]
total_public_playlists_count	92
has_spotify_name	true
has_spotify_image	true
color	5282805
allow_follows	true
show_follows	true

To follow and unfollow it requres a different api call a POST call to https://api-partner.spotify.com/pathfinder/v2/query with the JSON roughly set as:

Key Value
extensions {…}
persistedQuery {…}
sha256Hash "asdfgafsgag"
version 1
operationName "unfollowUsers"
variables {…}
usernames ["michaeljesse"]

But just focus on the requesting user-profile-view for now. If you need any help with that just let me know.

Please feel free to disregard this advice if you dont want/need it but when I started contributing I did the same thing and got very burnt out.

@secondlnl
Copy link
Contributor Author

secondlnl commented Jun 30, 2025

How do I add the images field to the initializer in webapi client without having it called in the sidebar, or do I need to implement a new struct.
Sidebar error:
Sidebar error caused by json maybe

Client.rs

543                 ),
544                 images: Vector::new(),
545             },

@SO9010
Copy link
Collaborator

SO9010 commented Jun 30, 2025

The API on the Spotify site is only really meant for the current user, not for public users in general (do correct me if I'm wrong though!). The API that Spotify actually uses - like in their Web Player - seems to have access to public playlists and a lot more.

Right now, we're using a mix of both: the official APIs they provide and the ones used by their Web Player. For this feature specifically, I think we'll need to use the latter - the one that isn't directly provided. But yeah, like I said before, I'm more than happy to help with it :)

As for the image issue - I think it's to do with how the struct is being deserialized hence the JSON error message. You may also need to use Option in case there are no images. I can't properly check the code at the moment, but if you're just calling Vec: : new() you're not actually putting any data in, right? I'll have a better look at it soon though.

@SO9010
Copy link
Collaborator

SO9010 commented Jun 30, 2025

Hey! I had a quick look at your get_publicuser_info function - it looks like you might are calling the endpoint for artists, which isn't quite the one we need here. Did you get a chance to use the info I sent about the correct endpoint to call? Unless I'm misunderstanding something, it seems like it's just the wrong type of request. Let me know if I've got that wrong though! :)

@secondlnl
Copy link
Contributor Author

Did you get a chance to use the info I sent about the correct endpoint to call? Unless I'm misunderstanding something, it seems like it's just the wrong type of request. Let me know if I've got that wrong though! :)

You didn't get it wrong, and I've now probably "fixed" at least that?

@SO9010
Copy link
Collaborator

SO9010 commented Jul 1, 2025

I ran your fork and I'm a bit confused about the changes? Could you explain the changes and perhaps why playlist details aren't shown properly and what you have changed to the left hand panel? They generally for this don't need to be touched apart from making the user name clickable. It may help me understand what you have done if you talk me through it?

Also could you commit the changes all in one go with a roughly detailed name as its so much harder to read the changes of each commit. Also please do use clippy to format the code regularly so it makes it easier to read :)

Edit: I'm a bit confused about why the playlist info isn't loading on your fork your change should be ok?

@secondlnl
Copy link
Contributor Author

Implementing the images field in the webapi initializer, made the error happen, if I comment it out and then also comment out the field and its function in user data and comment out the cover_widget and public_user_widget in user UI, it works. Sorry for the mess.

@SO9010
Copy link
Collaborator

SO9010 commented Jul 1, 2025

@secondlnl
Copy link
Contributor Author

Or not

@SO9010
Copy link
Collaborator

SO9010 commented Jul 1, 2025

Oh you added skip serialising you need skip deserialising :) or just use skip :) to skip both

@SO9010
Copy link
Collaborator

SO9010 commented Jul 1, 2025

https://serde.rs/field-attrs.html#skip

#[serde(skip_serializing_if = "path")]

@SO9010
Copy link
Collaborator

SO9010 commented Jul 1, 2025

But then you have to populate the images struct using a different API, (perhaps the one mentioned before)

@secondlnl
Copy link
Contributor Author

So the API things, how do they work?

@SO9010
Copy link
Collaborator

SO9010 commented Jul 2, 2025

What do you mean?

@secondlnl
Copy link
Contributor Author

secondlnl commented Jul 2, 2025 via email

@SO9010
Copy link
Collaborator

SO9010 commented Jul 5, 2025

Heya I think I'll have time in the evening to work out the API, it's a bit trickier than the normal ones as I need to sit there and watch Spotify make it's requests on the web app version. I think whas going wrong with yours is that your using the id which is an encoded id, but for the call you want to make you need to have the original username or the end bit of something like this spotify:user:michaeljesse. To find that I'm not sure yet but I'll give it a go this evening.

@SO9010
Copy link
Collaborator

SO9010 commented Jul 6, 2025

Ok so I've had a look through and did a few small changes, the api now works correctly, and all you need to do (still not an easy feat but you should be able to do it as you got it to work 90% with userProfile)! So you are very close now! Great job! If you need my help again just let me know! I added PublicUserDetail which now contains.

pub uri: String,
pub name: String,
pub image_url: String,
pub followers_count: i64,
pub following_count: i64,
pub is_following: bool,
pub recently_played_artists: Vec<RecentlyPlayedArtist>,
pub public_playlists: Vec<PublicPlaylist>,
pub total_public_playlists_count: i64,
pub allow_follows: bool,
pub show_follows: bool,

Which will make it far easier now ;)

@secondlnl
Copy link
Contributor Author

secondlnl commented Jul 20, 2025 via email

@secondlnl
Copy link
Contributor Author

Will have to step away, good luck.

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.

Public user viewer section

3 participants