cleaned up todos
This commit is contained in:
parent
a1f237c1c8
commit
6b2f59c531
5 changed files with 22 additions and 41 deletions
|
|
@ -16,8 +16,7 @@ $SD.onConnected((jsn) => {
|
|||
Utils.debounce(150, () => {
|
||||
const value = Utils.getFormValue(form);
|
||||
$SD.sendToPlugin(value, context);
|
||||
$SD.setSettings(value);
|
||||
console.log(value);
|
||||
$SD.setSettings(value, context);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ $SD.onConnected(({ actionInfo, appInfo, connection, messageType, port, uuid }) =
|
|||
.onDeviceDidDisconnect(() => {
|
||||
console.log({ object: 'stream-deck', event: 'onDeviceDidDisconnect' });
|
||||
})
|
||||
.onSendToPropertyInspector(() => {
|
||||
console.log({ object: 'stream-deck', event: 'onSendToPropertyInspector' });
|
||||
})
|
||||
.onApplicationDidLaunch(() => {
|
||||
console.log({ object: 'stream-deck', event: 'onApplicationDidLaunch' });
|
||||
})
|
||||
|
|
@ -57,7 +54,4 @@ new Action('com.elgato.template.action')
|
|||
})
|
||||
.onSendToPlugin(() => {
|
||||
console.log({ object: 'action', event: 'onSendToPlugin' });
|
||||
})
|
||||
.onSendToPropertyInspector(() => {
|
||||
console.log({ object: 'action', event: 'onSendToPropertyInspector' });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -101,15 +101,6 @@ class ELGSDAction {
|
|||
this.#on(`${this.UUID}.${Events.sendToPlugin}`, (jsn) => fn(jsn));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback function for the sendToPropertyInspector event, which fires when the plugin uses the sendToPropertyInspector api
|
||||
* @param {function} fn
|
||||
*/
|
||||
onSendToPropertyInspector(fn) {
|
||||
this.#on(`${this.UUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
const Action = ELGSDAction;
|
||||
|
|
|
|||
|
|
@ -55,17 +55,15 @@ const Events = {
|
|||
registerPropertyInspector: 'registerPropertyInspector',
|
||||
registerPlugin: 'registerPlugin',
|
||||
logMessage: 'logMessage',
|
||||
switchToProfile: 'switchToProfile'
|
||||
}
|
||||
switchToProfile: 'switchToProfile',
|
||||
};
|
||||
|
||||
/**
|
||||
* Constants used for Stream Deck
|
||||
*/
|
||||
const Constants = {
|
||||
dataLocalize: '[data-localize]',
|
||||
|
||||
//TODOZ: Try the things that use this in stream-deck.js to see if we really need it?
|
||||
hardwareAndSoftware : 0,
|
||||
hardwareOnly : 1,
|
||||
softwareOnly : 2,
|
||||
}
|
||||
hardwareAndSoftware: 0,
|
||||
hardwareOnly: 1,
|
||||
softwareOnly: 2,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
/// <reference path="event-emitter.js" />
|
||||
/// <reference path="constants.js" />
|
||||
|
||||
// TODO: See if we can add params for the call back function, so that the IDE will provide the jsn object with "context, device, etc"
|
||||
// TODO: https://stackoverflow.com/questions/24214962/whats-the-proper-way-to-document-callbacks-with-jsdoc
|
||||
|
||||
/**
|
||||
* @class StreamDeck
|
||||
* StreamDeck object containing all required code to establish
|
||||
|
|
@ -160,8 +157,9 @@ class ELGSDStreamDeck {
|
|||
* @param {object} [payload]
|
||||
*/
|
||||
send(event, context, payload = {}) {
|
||||
const pl = Object.assign({}, {event: event, context: context}, payload);
|
||||
this.websocket && this.websocket.send(JSON.stringify(pl)); }
|
||||
const pl = Object.assign({}, { event: event, context: context }, payload);
|
||||
this.websocket && this.websocket.send(JSON.stringify(pl));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the actions's persistent data. StreamDeck does not return the data, but trigger the actions's didReceiveSettings event
|
||||
|
|
@ -177,10 +175,10 @@ class ELGSDStreamDeck {
|
|||
* @param [context]
|
||||
*/
|
||||
setSettings(payload, context) {
|
||||
this.send(Events.setSettings, context ?? this.uuid, {
|
||||
this.send(Events.setSettings, this.uuid, {
|
||||
action: this?.actionInfo?.action,
|
||||
payload: payload || {},
|
||||
targetContext: this?.actionInfo?.context,
|
||||
targetContext: context,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -219,10 +217,10 @@ class ELGSDStreamDeck {
|
|||
* @param {string} [context]
|
||||
*/
|
||||
sendToPlugin(payload, context) {
|
||||
this.send(Events.sendToPlugin, context ?? this.uuid, {
|
||||
this.send(Events.sendToPlugin, this.uuid, {
|
||||
action: this?.actionInfo?.action,
|
||||
payload: payload || {},
|
||||
targetContext: this?.actionInfo?.context,
|
||||
targetContext: context,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -284,10 +282,10 @@ class ELGSDStreamDeck {
|
|||
* @param {object} payload
|
||||
* @param {string} context
|
||||
*/
|
||||
sendToPropertyInspector(payload, context) {
|
||||
sendToPropertyInspector(context, payload) {
|
||||
this.send(Events.sendToPropertyInspector, context, {
|
||||
action: this.actionInfo.action,
|
||||
payload: payload,
|
||||
action: this?.actionInfo?.action,
|
||||
payload: payload || {},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -307,11 +305,11 @@ class ELGSDStreamDeck {
|
|||
}
|
||||
|
||||
/**
|
||||
* Switches to a readonly profile or returns to previous profile
|
||||
* Switches to a readonly profile or returns to previous profile
|
||||
* @param {string} device
|
||||
* @param {string} [profile]
|
||||
*/
|
||||
switchToProfile(device, profile ) {
|
||||
switchToProfile(device, profile) {
|
||||
this.send(Events.switchToProfile, this.uuid, { device: device, payload: { profile } });
|
||||
}
|
||||
|
||||
|
|
@ -328,10 +326,11 @@ class ELGSDStreamDeck {
|
|||
/**
|
||||
* Registers a callback function for when Stream Deck sends data to the property inspector
|
||||
* @param {function} fn
|
||||
* @param {function} actionUUID
|
||||
* @returns ELGSDStreamDeck
|
||||
*/
|
||||
onSendToPropertyInspector(fn) {
|
||||
this.#on(Events.sendToPropertyInspector, (jsn) => fn(jsn));
|
||||
onSendToPropertyInspector(fn, actionUUID) {
|
||||
this.#on(`${actionUUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue