// A counter to track the indentation level.
$current_indent = 0;
+ $attach_history = $this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated();
foreach ($entities as $id => $entity) {
if ($build[$id]['#comment_threaded']) {
$build[$id]['#attached'] = [];
}
$build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer';
- if ($this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) {
+ if ($attach_history && $commented_entity->getEntityTypeId() === 'node') {
$build[$id]['#attached']['library'][] = 'comment/drupal.comment-new-indicator';
// Embed the metadata for the comment "new" indicators on this node.