Deduplicate code and fix a few clippy complaints#549
Merged
jacksongoode merged 1 commit intojpochyla:mainfrom Oct 24, 2024
Merged
Deduplicate code and fix a few clippy complaints#549jacksongoode merged 1 commit intojpochyla:mainfrom
jacksongoode merged 1 commit intojpochyla:mainfrom
Conversation
Collaborator
|
Awesome! Thank you for your contribution - I'll have a look now! |
jacksongoode
approved these changes
Oct 24, 2024
Collaborator
jacksongoode
left a comment
There was a problem hiding this comment.
Looks great! I'll merge it in!
Comment on lines
-1064
to
-1065
| self.send_empty_json(request)?; | ||
| Ok(()) |
Collaborator
There was a problem hiding this comment.
Ah thank you for taking care of these, I thought they might be redundant
Comment on lines
+1057
to
+1063
| // From https://github.com/KRTirtho/spotube/blob/9b024120601c0d381edeab4460cb22f87149d0f8/lib%2Fservices%2Fcustom_spotify_endpoints%2Fspotify_endpoints.dart keep and eye on this and change accordingly | ||
| const EXTENSIONS_JSON: &str = r#"{ | ||
| "persistedQuery": { | ||
| "version": 1, | ||
| "sha256Hash": "eb3fba2d388cf4fc4d696b1757a58584e9538a3b515ea742e9cc9465807340be" | ||
| } | ||
| }"#; |
Collaborator
There was a problem hiding this comment.
Wondering if there's a better place to put this, but here is fine for now.
Comment on lines
-1121
to
+1111
| // 0JQ5DAUnp4wcj0bCb3wh3S -> Daily mixes | ||
| let json_query = self.build_home_request("spotify:section:0JQ5DAUnp4wcj0bCb3wh3S"); | ||
| pub fn get_section(&self, section_uri: &str) -> Result<MixedView, Error> { | ||
| let request = self | ||
| .get("pathfinder/v1/query", Some("api-partner.spotify.com"))? | ||
| .query("operationName", "homeSection") | ||
| .query("variables", &json_query.0.to_string()) | ||
| .query("extensions", &json_query.1.to_string()); | ||
| .query("variables", &self.build_home_request(section_uri)?) | ||
| .query("extensions", EXTENSIONS_JSON); | ||
|
|
||
| // Extract the playlists | ||
| let result = self.load_and_return_home_section(request)?; | ||
| self.load_and_return_home_section(request) | ||
| } |
Collaborator
There was a problem hiding this comment.
Nice abstraction for this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While I was working on #548, I noticed a few areas where code was unnecessarily copied or did extra work/computation that it didn't need to do. Most of that was in the WebApi client struct, but there were a few other instances elsewhere as well. There were also some issues that clippy was complaining about which I took care of.
As far as I can tell, everything still works just as expected after these changes.