rweich / streamdeck-ts

A sdk to create streamdeck plugins in typescript.
MIT License
67 stars 4 forks source link

Seems broken with last update on Elgato Software #24

Closed qlaffont closed 2 years ago

qlaffont commented 2 years ago

Hello :), I try to create a new extension and with the same code (who is working before), now my property fields are not saved. I don't know why. Do you have the same issue (in dev mod or release mod) ? If needed, I can provided code.

PS: I'm using your template @rweich thanks for it ! My project was working 5 months ago. Try to update no success.

rweich commented 2 years ago

Hi i've just created a plugin as a test using a fresh install with the template and it works fine. Did you check the debugger for errors? If that doesn't help, please provide some (runnable) code.

qlaffont commented 2 years ago

No error at all during debug.

Repo: https://gitlab.com/qlaffont/exalty-lestudio-streamdeck-counter/-/tree/master

Thanks for your help ! :)

rweich commented 2 years ago

heya,

when you use pi.setSettings(uuid, { [parameter]: value }); in Propertyinspector.ts, you always override everything with just one key/value pair. if you want so save multiple key/value pairs, you need to pass all of them every time.

so basically you need to keep track of the other settings, you've already set. e.g.:

const settings: Record<string, unknown> = {};
const sendValueToPlugin = (value: string, parameter: string) => {
  settings[parameter] = value;
  pi.setSettings(uuid, settings);
};

and then the settings-keys when reading and writing are different. changing

sendValueToPlugin(event?.target?.value, 'setCounterActionType');

to

sendValueToPlugin(event?.target?.value, 'counterActionType');

should fix that

qlaffont commented 2 years ago

EDIT: Seems to works thanks !

qlaffont commented 2 years ago

PS: Finally it wasn't the only issue, event change since last time I installed deps :

plugin.on('didReceiveSettings', (event) => {
  const settings = event.settings as Record<string, unknown>;

after

plugin.on('didReceiveSettings', ({eventPayload}) => {
  const event = eventPayload.payload;
  const context = eventPayload.context;
  const settings = event.settings as Record<string, unknown>;
rweich commented 2 years ago

that doesn't seem right. i'm not exposing eventPayload because the values in event point to the ones in eventPayload... so event.settings should yield the same result as (the unexposed) event.eventPayload.payload.settings.

i do get errors with your Plugin.ts, but they seem related to uninitialized variables rather than the event object. and i guess i've got an old version of your codebase now anyways. seems you've set it private now.

i really don't want you to access that property directy and clutter your code with ts-ignores (which i guess you need to do that). so if you'd like, i can take another look at that.