summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/comment/js/node-new-comments-link.js
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/comment/js/node-new-comments-link.js')
-rw-r--r--core/modules/comment/js/node-new-comments-link.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/modules/comment/js/node-new-comments-link.js b/core/modules/comment/js/node-new-comments-link.js
index b7439940f61a..a3a821ddd140 100644
--- a/core/modules/comment/js/node-new-comments-link.js
+++ b/core/modules/comment/js/node-new-comments-link.js
@@ -21,7 +21,7 @@
function processNodeNewCommentLinks($placeholders) {
var $placeholdersToUpdate = {};
var fieldName = 'comment';
- var $placeholder = void 0;
+ var $placeholder;
$placeholders.each(function (index, placeholder) {
$placeholder = $(placeholder);
var timestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10);
@@ -35,8 +35,8 @@
remove($placeholder);
}
});
-
var nodeIDs = Object.keys($placeholdersToUpdate);
+
if (nodeIDs.length === 0) {
return;
}
@@ -56,7 +56,10 @@
$.ajax({
url: Drupal.url('comments/render_new_comments_node_links'),
type: 'POST',
- data: { 'node_ids[]': nodeIDs, field_name: fieldName },
+ data: {
+ 'node_ids[]': nodeIDs,
+ field_name: fieldName
+ },
dataType: 'json',
success: render
});
@@ -70,9 +73,9 @@
var $placeholder = $(this);
var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10);
var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id');
+
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
nodeIDs.push(nodeID);
-
hide($placeholder);
return true;
}