changeset 1812:a49ad994b467

dead code rm, more debugging of settings corruption. i think it's from partially-loaded graphs Ignore-this: 8d8f5e7367046b8e371b129b5bd1261d
author drewp@bigasterisk.com
date Fri, 08 Jun 2018 11:08:34 +0000
parents 341e03b9b10a
children 623346df401a
files light9/web/live/live.coffee
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/live/live.coffee	Fri Jun 08 10:44:50 2018 +0000
+++ b/light9/web/live/live.coffee	Fri Jun 08 11:08:34 2018 +0000
@@ -231,8 +231,11 @@
     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)
@@ -323,9 +326,6 @@
   clearSettings: ->
     @activeSettings.clear()
 
-  effectSettingLookup: (device, attr) ->
-    @activeSettings.effectSettingLookup(device, attr)
-
   register: (device, deviceAttr, graphValueChanged) ->
     @activeSettings.registerWidget(device, deviceAttr, graphValueChanged)
 
@@ -343,7 +343,7 @@
     # 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)
@@ -416,15 +416,14 @@
     @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