17
17
18
18
import LogController from '../Log/Controller.js'
19
19
import { isCustomVariableValid } from '@companion-app/shared/CustomVariable.js'
20
- import type { VariablesValues } from './Values.js'
20
+ import type { VariablesValues , VariableValueEntry } from './Values.js'
21
21
import type {
22
22
CustomVariablesModel ,
23
23
CustomVariableUpdate ,
@@ -174,9 +174,9 @@ export class VariablesCustomVariable {
174
174
init ( ) : void {
175
175
// Load the startup values of custom variables
176
176
if ( Object . keys ( this . #custom_variables) . length > 0 ) {
177
- const newValues : Record < string , CompanionVariableValue > = { }
177
+ const newValues : VariableValueEntry [ ] = [ ]
178
178
for ( const [ name , info ] of Object . entries ( this . #custom_variables) ) {
179
- newValues [ name ] = info . defaultValue || ''
179
+ newValues . push ( { id : name , value : info . defaultValue || '' } )
180
180
}
181
181
this . #variableValues. setVariableValues ( CUSTOM_LABEL , newValues )
182
182
}
@@ -186,14 +186,14 @@ export class VariablesCustomVariable {
186
186
* Replace all of the current custom variables with new ones
187
187
*/
188
188
replaceDefinitions ( custom_variables : CustomVariablesModel ) : void {
189
- const newValues : Record < string , CompanionVariableValue | undefined > = { }
189
+ const newValues : VariableValueEntry [ ] = [ ]
190
190
// Mark the current variables as to be deleted
191
191
for ( const name of Object . keys ( this . #custom_variables || { } ) ) {
192
- newValues [ name ] = undefined
192
+ newValues . push ( { id : name , value : undefined } )
193
193
}
194
194
// Determine the initial values of the variables
195
195
for ( const [ name , info ] of Object . entries ( custom_variables || { } ) ) {
196
- newValues [ name ] = info . defaultValue || ''
196
+ newValues . push ( { id : name , value : info . defaultValue || '' } )
197
197
}
198
198
199
199
const namesBefore = Object . keys ( this . #custom_variables)
@@ -358,9 +358,7 @@ export class VariablesCustomVariable {
358
358
* Helper for setting the value of a custom variable
359
359
*/
360
360
#setValueInner( name : string , value : CompanionVariableValue | undefined ) : void {
361
- this . #variableValues. setVariableValues ( CUSTOM_LABEL , {
362
- [ name ] : value ,
363
- } )
361
+ this . #variableValues. setVariableValues ( CUSTOM_LABEL , [ { id : name , value : value } ] )
364
362
365
363
this . #persistCustomVariableValue( name , value )
366
364
}
0 commit comments