Skip to content

Commit

Permalink
Refactor app.js to remove redundant code in ciderPlaybackAction handler
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptofyre committed Aug 24, 2024
1 parent 27fea93 commit ad5c987
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/sh.cider.streamdeck.sdPlugin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,6 @@ Object.keys(actions).forEach(actionKey => {
case 'ciderLogoAction':
console.warn(`[DEBUG] [Action] User must be high, why you clicking the logo?`);
break;
case 'ciderPlaybackAction':
switch (tapBehavior) {
case 'addToLibrary':
addToLibrary();
break;
case 'favorite':
setRating(1);
break;
default:
addToLibrary();
setRating(1);
break;
}
break;
default:
console.warn(`[DEBUG] [Action] No handler for ${actionKey}`);
break;
Expand All @@ -153,7 +139,7 @@ Object.keys(actions).forEach(actionKey => {
if (actionKey === 'ciderPlaybackAction') {
action.onDialDown(() => {
console.debug(`[DEBUG] [Action] ciderPlaybackAction dial pressed`);
switch (pressBehavior) {
switch (window.pressBehavior) {
case 'togglePlay':
comRPC("POST", "playpause");
break;
Expand All @@ -169,6 +155,22 @@ Object.keys(actions).forEach(actionKey => {
action.onDialRotate((jsonObj) => {
handleVolumeChange(actions.ciderPlaybackAction, window.contexts.ciderPlaybackAction[0], null, jsonObj.payload);
});

action.onTouchTap(() => {
console.debug(`[DEBUG] [Action] ciderPlaybackAction touch tapped`);
switch (window.tapBehavior) {
case 'addToLibrary':
addToLibrary();
break;
case 'favorite':
setRating(1);
break;
case 'both':
addToLibrary();
setRating(1);
break;
}
});
}
});

Expand Down

0 comments on commit ad5c987

Please sign in to comment.