Changeset - a49ad994b467
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 7 years ago 2018-06-08 11:08:34
drewp@bigasterisk.com
dead code rm, more debugging of settings corruption. i think it's from partially-loaded graphs
Ignore-this: 8d8f5e7367046b8e371b129b5bd1261d
1 file changed with 8 insertions and 9 deletions:
0 comments (0 inline, 0 general)
light9/web/live/live.coffee
Show inline comments
 
@@ -228,14 +228,17 @@ class ActiveSettings
 
    if @settings.has(key)
 
      return @settings.get(key).setting
 

	
 
    return null
 

	
 
  deleteSetting: (setting) ->
 
    log('deleteSetting ' + setting.value)
 
    key = @keyForSetting.get(setting.value)
 
    row = @settings.get(key)
 
    if row? and not row.setting.equals(setting)
 
      throw new Error('corrupt row for ' + setting.value)
 
    row.onChangeFunc(null) if row?.onChangeFunc?
 
    @settings.delete(key)
 
    @keyForSetting.delete(setting)
 

	
 
  clear: ->
 
    new Map(@settings).forEach (row, key) ->
 
@@ -320,15 +323,12 @@ class GraphToControls
 
    for settingStr in Array.from(toClear)
 
      @activeSettings.deleteSetting(U(settingStr))
 

	
 
  clearSettings: ->
 
    @activeSettings.clear()
 

	
 
  effectSettingLookup: (device, attr) ->
 
    @activeSettings.effectSettingLookup(device, attr)
 

	
 
  register: (device, deviceAttr, graphValueChanged) ->
 
    @activeSettings.registerWidget(device, deviceAttr, graphValueChanged)
 

	
 
  shouldBeStored: (deviceAttr, value) ->
 
    # this is a bug for zoom=0, since collector will default it to
 
    # stick at the last setting if we don't explicitly send the
 
@@ -340,13 +340,13 @@ class GraphToControls
 
    @activeSettings.forAll(@_removeEffectSetting.bind(@))
 

	
 
  controlChanged: (device, deviceAttr, value) ->
 
    # value is float or #color or (Uri or null)
 
    if (value == undefined or (typeof value == "number" and isNaN(value)) or (typeof value == "object" and value != null and not value.id))
 
      throw new Error("controlChanged sent bad value " + value)
 
    effectSetting = @effectSettingLookup(device, deviceAttr)
 
    effectSetting = @activeSettings.effectSettingLookup(device, deviceAttr)
 
    if @shouldBeStored(deviceAttr, value)
 
      if not effectSetting?
 
        @_addEffectSetting(device, deviceAttr, value)
 
      else
 
        @_patchExistingEffectSetting(effectSetting, deviceAttr, value)
 
    else
 
@@ -413,21 +413,20 @@ coffeeElementSetup(class Light9LiveContr
 
    @currentSettings = {}
 

	
 
  onGraph: ->
 
    @graphToControls = new GraphToControls(@graph)
 
    @graph.runHandler(@update.bind(@), 'Light9LiveControls update')
 

	
 
    # need graph to be loaded, so we don't make double settings? not sure.
 
    setTimeout(@setFromUrl.bind(@), 1)
 

	
 
  setFromUrl: ->
 
    effect = new URL(window.location.href).searchParams.get('effect')
 
    if effect?
 
      @effectChoice = effect
 

	
 
  effectSettingLookup: (device, attr) ->
 
    if @graphToControls == null
 
      throw new Error('not ready')
 
    return @graphToControls.effectSettingLookup(device, attr)
 

	
 
  newEffect: ->
 
    @effectChoice = @graphToControls.newEffect().value
 
      
 
  onEffectChoice: ->
 
    U = (x) => @graph.Uri(x)
 
    if not @effectChoice?
0 comments (0 inline, 0 general)