summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-01-02 16:29:08 +0300
committerAndrew Dolgov <[email protected]>2019-01-02 16:29:08 +0300
commitc66db9bde8996dd9dc862bee9220e71015609b9c (patch)
treed9bcea29ef3a54b8d2157a2264f54d6b17a0fa86 /js
parent60b40d39e832d27dad503022b0f8d59324afd82d (diff)
headlines onloaded: when appending, check for duplicate IDs
Diffstat (limited to 'js')
-rwxr-xr-xjs/Headlines.js17
1 files changed, 12 insertions, 5 deletions
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
+});