Explorar el Código

Fixed issue of no channels being selected when local storage is unitialized

Taddeus Kroes hace 12 años
padre
commit
7bca830d1c
Se han modificado 1 ficheros con 5 adiciones y 6 borrados
  1. 5 6
      guide.coffee

+ 5 - 6
guide.coffee

@@ -46,10 +46,6 @@ ChannelList = Backbone.Collection.extend(
     model: Channel
     comparator: (a, b) -> parseInt(a.get('id')) - parseInt(b.get('id'))
 
-    initialize: (models, options) ->
-        @visible = if localStorage.hasOwnProperty(STORAGE_NAME) \
-            then localStorage.getItem(STORAGE_NAME).split(',') else @pluck('id')
-
     fetch: ->
         @reset(CHANNELS)
         #@reset(CHANNELS.slice(0,3))
@@ -57,12 +53,15 @@ ChannelList = Backbone.Collection.extend(
         @propagateVisible()
 
     propagateVisible: ->
-        for id in @visible
+        visible = if localStorage.hasOwnProperty(STORAGE_NAME) \
+            then localStorage.getItem(STORAGE_NAME).split(',') else @pluck('id')
+
+        for id in visible
             if @length and not @findWhere(id: id)
                 console.log 'not found:', id, typeof id, typeof @at(0).get('id')
             @findWhere(id: id)?.set(visible: true)
 
-        for id in _.difference(@pluck('id'), @visible)
+        for id in _.difference(@pluck('id'), visible)
             if not @findWhere(id: id)
                 console.log 'not found:', id
             @findWhere(id: id)?.set(visible: false)