From: Jaroslav Kysela Date: Mon, 12 Oct 2015 11:23:02 +0000 (+0200) Subject: WEBUI: EPG - cleanups in the comet code X-Git-Tag: v4.2.1~1937 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71861fd04003931cc6a013f959ab822b97c0f3e1;p=thirdparty%2Ftvheadend.git WEBUI: EPG - cleanups in the comet code --- diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index d4be5df7e..16d824cec 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -938,18 +938,9 @@ tvheadend.epg = function() { }, success: function(d) { d = json_decode(d); - for (var i = 0; i < d.length; i++) { - var r = epgStore.getById(d[i].eventId); - if (r) { - for (var j = 0; j < r.store.fields.items.length; j++) { - var n = r.store.fields.items[j]; - var v = d[i][n.name]; - r.data[n.name] = n.convert((v !== undefined) ? v : n.defaultValue, v); - } - r.json = d[i]; - r.commit(); - } - } + Ext.each(d, function(jd) { + tvheadend.replace_entry(epgStore.getById(jd.eventId), jd); + }); }, failure: function(response, options) { Ext.MessageBox.alert(_('EPG Update'), response.statusText); diff --git a/src/webui/static/app/tvheadend.js b/src/webui/static/app/tvheadend.js index 4c8d4346c..ed432962e 100644 --- a/src/webui/static/app/tvheadend.js +++ b/src/webui/static/app/tvheadend.js @@ -164,6 +164,20 @@ tvheadend.doQueryAnyMatch = function(q, forceAll) { } } +/* + * Replace one entry + */ + +tvheadend.replace_entry = function(r, d) { + if (!r) return; + r.store.fields.each(function (n) { + var v = d[n.name]; + r.data[n.name] = n.convert((v !== undefined) ? v : n.defaultValue, v); + }); + r.json = d; + r.commit(); +} + /* * General capabilities */