headlines onloaded: when appending, check for duplicate IDs

This commit is contained in:
Andrew Dolgov 2019-01-02 16:29:08 +03:00
parent 60b40d39e8
commit c66db9bde8
1 changed files with 12 additions and 5 deletions

View File

@ -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;
});
});