advanced syntaxes: restore stupid-simple resolution order, deduping value changes brings more problem than it solves

history: fe682693b1, 0e54c11f13, 182941a22c, 3a5fdf17c7, 8b92400c1e
This commit is contained in:
jean-emmanuel 2024-03-13 18:04:43 +01:00
parent 1a4b971b18
commit 0e68557b85
5 changed files with 9 additions and 39 deletions

View file

@ -43,8 +43,6 @@ function updateWidget(widget, options={}) {
return
}
widgetManager.valueChangeLock()
var reuseChildren = options.reuseChildren !== false && widget instanceof Panel
&& !(widget instanceof Matrix)
@ -148,8 +146,6 @@ function updateWidget(widget, options={}) {
}
}
widgetManager.valueChangeUnlock()
editor.widgetTree.updateTree(editor.selectedWidgets)
if (editor.selectedWidgets.includes(widget) && !options.preventSelect) {

View file

@ -19,9 +19,6 @@ class WidgetManager extends EventEmitter {
this.preArgsSeparator = '||||'
this.valueChangeLockDepth = 0
this.valueChangeQueue = {}
this.on('value-changed', this.onChange.bind(this))
ipc.on('connect', ()=>{
@ -32,28 +29,9 @@ class WidgetManager extends EventEmitter {
}
valueChangeLock() {
this.valueChangeLockDepth++
}
valueChangeUnlock() {
this.valueChangeLockDepth--
if (this.valueChangeLockDepth == 0) {
for (var h in this.valueChangeQueue) {
if (this.valueChangeQueue[h]) this.applyValueChange(this.valueChangeQueue[h])
}
this.valueChangeQueue = {}
}
}
onChange(e) {
if (this.valueChangeLockDepth === 0) this.applyValueChange(e)
else this.valueChangeQueue[e.widget.hash] = e
}
applyValueChange(e) {
if (!e) return
var {id, widget, linkId, options} = e
@ -101,8 +79,6 @@ class WidgetManager extends EventEmitter {
this.linkIdLock = []
}
}
this.trigger('value-changed-lazy', e)
}
createAddressRef(widget, preArgs, address) {

View file

@ -43,8 +43,6 @@ var Parser = class Parser {
var props = data
widgetManager.valueChangeLock()
// Set default widget type
props.type = tab ? 'tab' : props.type || 'fader'
@ -109,8 +107,6 @@ var Parser = class Parser {
parentNode.appendChild(widget.container)
widget.mounted = true
widgetManager.valueChangeUnlock()
// Editor needs to get the container object
return widget

View file

@ -345,14 +345,12 @@ class Widget extends EventEmitter {
changed(options) {
widgetManager.valueChangeLock()
this.trigger('value-changed', {
widget: this,
options: options,
id: this.getProp('id'),
linkId: this.getProp('linkId')
})
widgetManager.valueChangeUnlock()
}
@ -487,11 +485,11 @@ class Widget extends EventEmitter {
this.onLinkedPropsChanged(e, 'value-changed')
}
widgetManager.on('value-changed-lazy', this.linkedValueChangedCallback, {context: this})
widgetManager.on('value-changed', this.linkedValueChangedCallback, {context: this})
} else if (this.linkedPropsValueCallback && !Object.keys(this.linkedPropsValue).length) {
widgetManager.off('value-changed-lazy', this.linkedValueChangedCallback)
widgetManager.off('value-changed', this.linkedValueChangedCallback)
delete this.linkedValueChangedCallback
}

View file

@ -199,7 +199,9 @@ class Panel extends Container() {
this.navigation = this.widget.appendChild(html`<div class="navigation ${'tabs-' + this.getProp('tabsPosition')}"></div>`)
this.children = options.children || new Array(this.getProp('tabs').length)
for (let i = 0; i < this.children.length; i++) {
var length = this.children.length
for (let i = 0; i < length; i++) {
if (this.children[i]) {
this.widget.appendChild(this.children[i].container)
this.children[i].mounted = true
@ -240,7 +242,9 @@ class Panel extends Container() {
this.childrenType = 'widget'
this.children = options.children || new Array(this.getProp('widgets').length)
for (let i = 0; i < this.children.length; i++) {
var length = this.children.length
for (let i = 0; i < length; i++) {
if (this.children[i]) {
this.widget.appendChild(this.children[i].container)
this.children[i].mounted = true