Procházet zdrojové kódy

Fixed a parsing issue causing programs that were loaded not being shown in the guide

Taddeus Kroes před 12 roky
rodič
revize
959ec0fd2d
1 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. 5 1
      guide.coffee

+ 5 - 1
guide.coffee

@@ -79,6 +79,10 @@ ChannelList = Backbone.Collection.extend(
             @findWhere(id: id)?.set(visible: false)
 
     fetchPrograms: (day) ->
+        # Sometimes a program list is an object (PHP's json_encode() is
+        # probably given an associative array)
+        to_array = (o) -> if o.length? then o else _.map(o, ((v, k) -> v))
+
         $('#loading-screen').show()
         $.getJSON(
             'programs.php'
@@ -96,7 +100,7 @@ ChannelList = Backbone.Collection.extend(
                             end: parse_date(p.datum_end)
                             article_id: p.artikel_id
                             article_title: p.artikel_titel
-                        ) for p in programs
+                        ) for p in to_array(programs)
                     )) if channel?
                 $('#loading-screen').hide()
         )