Commit 7bca830d authored by Taddeüs Kroes's avatar Taddeüs Kroes

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

parent 6ad0782d
...@@ -46,10 +46,6 @@ ChannelList = Backbone.Collection.extend( ...@@ -46,10 +46,6 @@ ChannelList = Backbone.Collection.extend(
model: Channel model: Channel
comparator: (a, b) -> parseInt(a.get('id')) - parseInt(b.get('id')) 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: -> fetch: ->
@reset(CHANNELS) @reset(CHANNELS)
#@reset(CHANNELS.slice(0,3)) #@reset(CHANNELS.slice(0,3))
...@@ -57,12 +53,15 @@ ChannelList = Backbone.Collection.extend( ...@@ -57,12 +53,15 @@ ChannelList = Backbone.Collection.extend(
@propagateVisible() @propagateVisible()
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) if @length and not @findWhere(id: id)
console.log 'not found:', id, typeof id, typeof @at(0).get('id') console.log 'not found:', id, typeof id, typeof @at(0).get('id')
@findWhere(id: id)?.set(visible: true) @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) if not @findWhere(id: id)
console.log 'not found:', id console.log 'not found:', id
@findWhere(id: id)?.set(visible: false) @findWhere(id: id)?.set(visible: false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment