Skip to content

Commit

Permalink
Remove duplicated micro-updates, if found
Browse files Browse the repository at this point in the history
This could be handled with a different approach but, as my JS skills are limited, I was not able to find it.

Main problem is the view returning HTML instead of JSON or XML; but that would complicate the JS code as each element has a bunch of tags.
  • Loading branch information
hvelarde committed Sep 12, 2014
1 parent ab0886b commit a16a23f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/collective/liveblog/browser/templates/update.pt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@
url: "recent-updates",
success: function (data) {
$("#micro-updates").prepend(data).fadeIn("slow");
/* in some cases a micro-update could be duplicated; remove it */
var seen = {};
$(".microupdate").each(function () {
var timestamp = $(this).attr("data-timestamp");
if (seen[timestamp]) {
$(this).remove();
} else {
seen[timestamp] = true;
}
});
},
statusCode: {
205: function () {
Expand Down
10 changes: 10 additions & 0 deletions src/collective/liveblog/browser/templates/view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
url: "recent-updates",
success: function (data) {
$("#micro-updates").prepend(data).fadeIn("slow");
/* in some cases a micro-update could be duplicated; remove it */
var seen = {};
$(".microupdate").each(function () {
var timestamp = $(this).attr("data-timestamp");
if (seen[timestamp]) {
$(this).remove();
} else {
seen[timestamp] = true;
}
});
},
statusCode: {
205: function () {
Expand Down

0 comments on commit a16a23f

Please sign in to comment.