Skip to content

Commit

Permalink
Declare like/dislike commands in package.json
Browse files Browse the repository at this point in the history
Also fix some casing of command IDs
  • Loading branch information
sedders123 committed Sep 6, 2022
1 parent f5a58e2 commit 6b3b1ed
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"category": "Youtube Music"
},
{
"command": "ytMusic.playpause",
"command": "ytMusic.playPause",
"title": "Toggle Play Pause",
"category": "Youtube Music"
},
Expand All @@ -70,6 +70,16 @@
"command": "ytMusic.cycleRepeat",
"title": "Cycle Repeat Mode",
"category": "Youtube Music"
},
{
"command": "ytMusic.thumbsUp",
"title": "Thumbs Up Current Song",
"category": "Youtube Music"
},
{
"command": "ytMusic.thumbsDown",
"title": "Thumbs Down Current Song",
"category": "Youtube Music"
}
],
"icons":{
Expand Down Expand Up @@ -125,4 +135,4 @@
"socket.io-client": "2.5.0",
"vscode-cache": "0.3.0"
}
}
}
15 changes: 9 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import YouTubeMusic from "./youtubeMusic";
export function activate(context: ExtensionContext) {
let ytMusic = new YouTubeMusic(context);

const playpauseCommand = commands.registerCommand("ytMusic.playpause", () => {
const playPauseCommand = commands.registerCommand("ytMusic.playPause", () => {
ytMusic.togglePlay();
});
const skipCommand = commands.registerCommand("ytMusic.skip", () => {
Expand All @@ -28,15 +28,18 @@ export function activate(context: ExtensionContext) {
ytMusic.auth();
});

const thumbsUpCommand = commands.registerCommand("ytMusic.thumbsup", () => {
const thumbsUpCommand = commands.registerCommand("ytMusic.thumbsUp", () => {
ytMusic.thumbsUp();
});

const thumbsDownCommand = commands.registerCommand("ytMusic.thumbsdown", () => {
ytMusic.thumbsDown();
});
const thumbsDownCommand = commands.registerCommand(
"ytMusic.thumbsDown",
() => {
ytMusic.thumbsDown();
}
);

context.subscriptions.push(playpauseCommand);
context.subscriptions.push(playPauseCommand);
context.subscriptions.push(skipCommand);
context.subscriptions.push(rewindCommand);
context.subscriptions.push(restartCommand);
Expand Down
17 changes: 10 additions & 7 deletions src/youtubeMusic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ export default class YouTubeMusic {
this._repeat = data.player.repeatType;
this.updateRepeatButtonState();
this.refreshNowPlaying();
this.updateDynamicButton("playpause", !this._isPaused);
this.updateDynamicButton("thumbsup", data.player.likeStatus === 'LIKE');
this.updateDynamicButton("thumbsdown", data.player.likeStatus === 'DISLIKE');
this.updateDynamicButton("playPause", !this._isPaused);
this.updateDynamicButton("thumbsUp", data.player.likeStatus === "LIKE");
this.updateDynamicButton(
"thumbsDown",
data.player.likeStatus === "DISLIKE"
);
});

socket.on("reconnect_error", (err) => {
Expand All @@ -108,7 +111,7 @@ export default class YouTubeMusic {
const buttons = [
{ id: "rewind", title: "Previous Song", text: "$(chevron-left)" },
{
id: "playpause",
id: "playPause",
title: "Play / Pause",
text: "$(triangle-right)",
dynamicText: (currentlyPlaying: boolean) =>
Expand All @@ -117,19 +120,19 @@ export default class YouTubeMusic {
{ id: "skip", title: "Next Song", text: "$(chevron-right)" },
{ id: "cycleRepeat", title: "Not Repeating", text: "$(sync)" },
{
id: "thumbsdown",
id: "thumbsDown",
title: "Thumbs Down",
text: "$(mui-thumbs-down)",
dynamicText: (isThumbsDown: boolean) =>
isThumbsDown ? "$(mui-thumbs-down-solid)" : "$(mui-thumbs-down)",
},
{
id: "thumbsup",
id: "thumbsUp",
title: "Thumbs Up",
text: "$(mui-thumbs-up)",
dynamicText: (isThumbsUp: boolean) =>
isThumbsUp ? "$(mui-thumbs-up-solid)" : "$(mui-thumbs-up)",
}
},
];

buttons.map((button) => {
Expand Down

0 comments on commit 6b3b1ed

Please sign in to comment.