<% cache("user-profile-comments-#{@user.last_comment_at}-#{@user.id}-#{@comments.size}", expires_in: 2.days) do %>
  <style>
    .index-comments header {
      color: <%= HexComparer.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).brightness(0.88) %>;
    }
    .night-theme .index-comments header {
      color: #cedae2;
    }
  </style>
  <div class="index-comments">
    <% if @comments.present? %>
      <% if params[:view] == "comments" %>
        <div class="breadcrumb"><a href="<%= @user.path %>">View All Activity</a></div>
        <header>
          <% if @user.comments_count > 250 %>
            <h4>Last 250 Comments</h4>
          <% else %>
            <h4>All <%= @user.comments_count %> Comments</h4>
          <% end %>
        </header>
      <% else %>
        <header>
          <h4>Recent Comments</h4>
        </header>
      <% end %>
    <% end %>
    <% @comments.each do |comment| %>
      <% if comment.commentable.present? && comment.commentable.published && !comment.deleted %>
        <a href="<%= comment.path %>">
          <div class="single-comment <%= "strong-comment" if comment.ancestry.nil? %>">
            <span class="comment-title">re: <%= comment.commentable.title %></span>
            <span class="comment-date">
              <time datetime="<%= comment.decorate.published_timestamp %>"><%= comment.readable_publish_date %></time>
            </span>
            <div class="comment-preview"><%= truncate(strip_tags(comment.processed_html), length: 64).html_safe %></div>
          </div>
        </a>
      <% end %>
    <% end %>
    <% if params[:view] != "comments" && @user.comments_count > 250 %>
      <div class="breadcrumb"><a href="<%= @user.path %>/comments">Last 250 Comments</a></div>
    <% elsif params[:view] != "comments" && @user.comments_count > 8 %>
      <div class="breadcrumb"><a href="<%= @user.path %>/comments">View All <%= @user.comments_count %> Comments</a>
      </div>
    <% end %>
  </div>
<% end %>
