-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility to use variables for broadcast selection in actions and feedbacks #115
base: master
Are you sure you want to change the base?
Conversation
Please add unit tests for your feature. |
{ | ||
type: 'checkbox', | ||
label: 'Use variables for broadcast selection', | ||
id: 'use_var', | ||
default: false | ||
}, | ||
{ | ||
type: 'dropdown', | ||
label: 'Broadcast:', | ||
id: 'broadcast_id', | ||
choices: [...broadcastEntries, ...broadcastUnfinishedEntries], | ||
default: defaultBroadcast, | ||
isVisible: (options) => options.use_var == false | ||
}, | ||
{ | ||
type: 'textinput', | ||
label: 'Broadcast', | ||
id: 'broadcast_vars', | ||
useVariables: true, | ||
tooltip: 'Use unfinished_ followed by a number to dynamically select an unfinished broadcast, or the Video ID for static selection', | ||
isVisible: (options) => options.use_var == true | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is becoming unmanageable. I think you should create a function createBroadcastChoices
that takes the varying aspects (like the choices
for the broadcast_id
), and returns an array with the use_var, broadcast_id and broadcast_vars elements. The function is then called with the correct parameters instead of the three elements:
{ | |
type: 'checkbox', | |
label: 'Use variables for broadcast selection', | |
id: 'use_var', | |
default: false | |
}, | |
{ | |
type: 'dropdown', | |
label: 'Broadcast:', | |
id: 'broadcast_id', | |
choices: [...broadcastEntries, ...broadcastUnfinishedEntries], | |
default: defaultBroadcast, | |
isVisible: (options) => options.use_var == false | |
}, | |
{ | |
type: 'textinput', | |
label: 'Broadcast', | |
id: 'broadcast_vars', | |
useVariables: true, | |
tooltip: 'Use unfinished_ followed by a number to dynamically select an unfinished broadcast, or the Video ID for static selection', | |
isVisible: (options) => options.use_var == true | |
}, | |
...createBroadcastChoices([...broadcastEntries, ...broadcastUnfinishedEntries]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should be made a lot more DRY. Repeating the same code 15 times is a bad idea.
@@ -16,6 +17,7 @@ export enum FeedbackId { | |||
|
|||
/** | |||
* Get a list of feedbacks for this module | |||
* @param The companion instance used to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param The companion instance used to |
if (event.options.use_var) { | ||
if (!event.options.broadcast_vars) return {}; | ||
} else { | ||
if (!event.options.broadcast) return {}; | ||
} | ||
const id = ( | ||
event.options.use_var | ||
? await context.parseVariablesInString(event.options.broadcast_vars as string) | ||
: event.options.broadcast | ||
) as BroadcastID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same, or very similar code, is present in this PR at least three times.
No description provided.