Skip to content

Commit

Permalink
Refactor app.js to use async/await for WebSocket communication and RP…
Browse files Browse the repository at this point in the history
…C calls
  • Loading branch information
cryptofyre committed Aug 13, 2024
1 parent cacbe46 commit dce9171
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sh.cider.streamdeck.sdPlugin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ async function checkAuthKey() {
}
}

function startWebSocket() {
async function startWebSocket() {
try {
const CiderApp = io('http://localhost:10767');

comRPC("GET", "now-playing").then(data => {
await comRPC("GET", "now-playing").then(data => {
if (data.status === "ok") {
setManualData(data.info);
setAdaptiveData(data.info);
Expand Down Expand Up @@ -223,7 +223,7 @@ async function setPlaybackStatus(status) {

async function addToLibrary() {
if (!window.addedToLibrary) {
comRPC("POST", "add-to-library", true);
await comRPC("POST", "add-to-library", true);
window.contexts.addToLibraryAction?.forEach(context => setImage(context, 'actions/playback/assets/check.png', 0));
window.addedToLibrary = true;
console.debug("[DEBUG] [Library] Added to library");
Expand All @@ -250,7 +250,7 @@ async function setVolume(direction) {

async function setRating(ratingValue) {
if (window.ratingCache !== ratingValue) {
comRPC("POST", "set-rating", true, { rating: ratingValue });
await comRPC("POST", "set-rating", true, { rating: ratingValue });

const likeIcon = ratingValue === 1 ? 'liked.png' : 'like.png';
const dislikeIcon = ratingValue === -1 ? 'disliked.png' : 'dislike.png';
Expand Down

0 comments on commit dce9171

Please sign in to comment.