From c66db9bde8996dd9dc862bee9220e71015609b9c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 2 Jan 2019 16:29:08 +0300 Subject: headlines onloaded: when appending, check for duplicate IDs --- js/Headlines.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/Headlines.js b/js/Headlines.js index 43837f65b..3685cd7ba 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -547,8 +547,6 @@ define(["dojo/_base/declare"], function (declare) { return; const headlines_count = reply['headlines-info']['count']; - Feeds.infscroll_disabled = parseInt(headlines_count) != 30; - console.log('received', headlines_count, 'headlines, infscroll disabled=', Feeds.infscroll_disabled); //this.vgroup_last_feed = reply['headlines-info']['vgroup_last_feed']; @@ -623,18 +621,27 @@ define(["dojo/_base/declare"], function (declare) { if (hsp) c.domNode.removeChild(hsp); + let headlines_appended = 0; + if (typeof reply['headlines']['content'] == 'string') { $("headlines-frame").innerHTML = reply['headlines']['content']; } else { for (let i = 0; i < reply['headlines']['content'].length; i++) { const hl = reply['headlines']['content'][i]; - $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); + if (!this.headlines[parseInt(hl.id)]) { + $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); - this.headlines[parseInt(hl.id)] = hl; + this.headlines[parseInt(hl.id)] = hl; + ++headlines_appended; + } } } + console.log('appended', headlines_appended, 'headlines'); + + Feeds.infscroll_disabled = headlines_appended != 30; + if (!hsp) { hsp = document.createElement("div"); hsp.id = "headlines-spacer"; @@ -1383,4 +1390,4 @@ define(["dojo/_base/declare"], function (declare) { } return Headlines; -}); \ No newline at end of file +}); -- cgit v1.2.3