diff options
Diffstat (limited to 'core/modules/comment/js')
-rw-r--r-- | core/modules/comment/js/comment-new-indicator.js | 4 | ||||
-rw-r--r-- | core/modules/comment/js/node-new-comments-link.js | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/core/modules/comment/js/comment-new-indicator.js b/core/modules/comment/js/comment-new-indicator.js index 88587d5724c3..a59a70803c82 100644 --- a/core/modules/comment/js/comment-new-indicator.js +++ b/core/modules/comment/js/comment-new-indicator.js @@ -9,8 +9,7 @@ function processCommentNewIndicators($placeholders) { var isFirstNewComment = true; var newCommentString = Drupal.t('new'); - var $placeholder = void 0; - + var $placeholder; $placeholders.each(function (index, placeholder) { $placeholder = $(placeholder); var timestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); @@ -40,6 +39,7 @@ var $placeholder = $(this); var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10); var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id'); + if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) { nodeIDs.push(nodeID); return true; 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; } |