-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(api-server): Improved api-server volume and like/dislike state #3592
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the API server by extending volume state with mute information and introducing a new like/dislike state endpoint.
- Add
VolumeState
type withisMuted
- Introduce setup and IPC for like/dislike changes in the front-end provider
- Update MPRIS, song-controls, and backend routes to handle
LikeType
andVolumeState
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/types/datahost-get-state.ts | Add VolumeState interface alongside existing enums |
src/providers/song-info-front.ts | Implement setupLikeChangedListener and enrich volume IPC with isMuted |
src/providers/song-controls.ts | Use LikeType enums for update-like IPC calls |
src/plugins/shortcuts/mpris.ts | Adapt MPRIS handler to consume VolumeState and mute logic |
src/plugins/api-server/backend/types.ts | Extend backend context type with LikeType and VolumeState |
src/plugins/api-server/backend/routes/control.ts | Define new getLikeState route and update getVolumeState schema |
src/plugins/api-server/backend/main.ts | Wire up ytmd:like-changed IPC and pass new getters to route registration |
Comments suppressed due to low confidence (2)
src/plugins/api-server/backend/routes/control.ts:90
- Add tests for the new
GET /api/v1/like-state
endpoint and update tests forGET /api/v1/volume-state
to verify theisMuted
field is returned correctly.
getLikeState: createRoute({
src/types/datahost-get-state.ts:48
- [nitpick] Consider adding a TSDoc comment above
VolumeState
to describe its purpose and fields (state
vsisMuted
) for clearer code documentation.
export interface VolumeState {
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
@JellyBrick hello, I've fixed copilot's comments, can you please merge this PR? |
: LikeType.Indifferent; | ||
|
||
export const setupLikeChangedListener = singleton(() => { | ||
const likeDislikeObserver = new MutationObserver((mutations) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the use of MutationObserver strictly necessary in this part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR includes a couple of small but useful improvements to the api-server:
Volume State Endpoint:
The volume state endpoint now includes a new
isMuted
boolean. It was a singlestate
volume level before, now it also hasisMuted
property, to detect whether volume button is pressed (just what the/v1/toggle-mute
does).New Like State Endpoint:
Added a new endpoint:
GET /v1/like-state
It returns the current song's like/dislike status, using the same values:
LIKE, DISLIKE, INDIFFERENT
as YouTube Music already has.