From af76f81b3635bfa3aa03c6f89d8a783426178645 Mon Sep 17 00:00:00 2001 From: Zack Hoherchak Date: Wed, 23 Feb 2022 19:07:21 -0500 Subject: [PATCH] notes --- .../libs/js/constants.js | 1 + .../libs/js/stream-deck.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/com.elgato.template.sdPlugin/libs/js/constants.js b/src/com.elgato.template.sdPlugin/libs/js/constants.js index 79d7399..ade315a 100644 --- a/src/com.elgato.template.sdPlugin/libs/js/constants.js +++ b/src/com.elgato.template.sdPlugin/libs/js/constants.js @@ -21,6 +21,7 @@ const SocketErrors = { /** * Events */ +//TODO: group these in objects that make sense & rename const DID_RECEIVE_SETTINGS = 'didReceiveSettings'; const DID_RECEIVE_GLOBAL_SETTINGS = 'didReceiveGlobalSettings'; const KEY_DOWN = 'keyDown'; diff --git a/src/com.elgato.template.sdPlugin/libs/js/stream-deck.js b/src/com.elgato.template.sdPlugin/libs/js/stream-deck.js index 31bd13b..07d46dd 100644 --- a/src/com.elgato.template.sdPlugin/libs/js/stream-deck.js +++ b/src/com.elgato.template.sdPlugin/libs/js/stream-deck.js @@ -1,6 +1,8 @@ -/// +/// /// +// TODO: add clearTitle, switchToProfile (see https://elgato.slack.com/archives/D02LPKC0M9D/p1645183819000839 ), swap optional context to be second everywhere + /** * @class StreamDeck * StreamDeck object containing all required code to establish @@ -80,7 +82,7 @@ class ELGSDStreamDeck { this.#websocket.onmessage = (evt) => { const data = evt?.data ? JSON.parse(evt.data) : {}; - const {action, event} = data; + const { action, event } = data; const message = action ? `${action}.${event}` : event; if (message && message !== '') this.#emit(message, data); @@ -91,7 +93,7 @@ class ELGSDStreamDeck { * Write to log file * @param message */ - log(message) { + logMessage(message) { try { if (this.#websocket) { const json = { @@ -159,7 +161,7 @@ class ELGSDStreamDeck { * @param payload */ send(context, fn, payload) { - const pl = Object.assign({}, {event: fn, context: context}, payload); + const pl = Object.assign({}, { event: fn, context: context }, payload); this.#websocket && this.#websocket.send(JSON.stringify(pl)); } @@ -252,7 +254,7 @@ class ELGSDStreamDeck { * @param context * @param payload */ - setState(context, payload) { + setState(payload, context) { this.send(context, SET_STATE, { payload: { state: 1 - Number(payload === 0), @@ -266,7 +268,7 @@ class ELGSDStreamDeck { * @param title * @param target */ - setTitle(context, title, target) { + setTitle(title, target, context) { this.send(context, SET_TITLE, { payload: { title: '' + title || '', @@ -280,7 +282,7 @@ class ELGSDStreamDeck { * @param context * @param payload */ - sendToPropertyInspector(context, payload) { + sendToPropertyInspector(payload, context) { this.send(context, SEND_TO_PROPERTY_INSPECTOR, { action: this.#actionInfo.action, payload: payload,