%ul#recent_activities{:class => "#{'refresh' if @page == 1}"}
  -@recent_channels.each do |channel|
    -last_post = @recent_posts[channel.id]
    -has_posts = channel.has_posts?(current_user, last_post)
    %li{:class => "#{'visited' if has_posts} channel", "data-last-id" => last_post.id}
      .name
        -if last_post
          .user-color{:style => "background-color: #{last_post.user.color}"}
          =render :partial => "shared/user", :object => last_post.user
        -else
          &nbsp;
      .date
        -if last_post && channel
          =link_to last_post.created_at.try(:strftime, '%Y/%m/%d %H:%M:%S'), channel_path(channel, :anchor => channel_anchor(channel, current_user, last_post))
        -else
          No Posts yet.
      -if (mentions = channel.num_mentions(current_user)) > 0
        .post-count.mentions= mentions
      =link_to format_title(channel), channel_path(channel), :class => "channel-link"

%br/
%br/
=will_paginate @recent_channels, :params => {:controller => "channels", :action => "index"}

%ul#recent_activities{:class => "#{'refresh' if @page == 1}"}
  -@recent_channels.each do |channel|
    -last_post = @recent_posts[channel.id]
    -has_posts = channel.has_posts?(current_user, last_post)
    %li{:class => "#{'visited' if has_posts} channel", "data-last-id" => (last_post.id rescue 0)}
      .name
        -if last_post
          .user-color{:style => "background-color: #{last_post.user.color}"}
          =render :partial => "shared/user", :object => last_post.user
        -else
          &nbsp;
      .date
        -if last_post && channel
          =link_to last_post.created_at.try(:strftime, '%Y/%m/%d %H:%M:%S'), channel_path(channel, :anchor => channel_anchor(channel, current_user, last_post))
        -else
          No Posts yet.
      -if (mentions = channel.num_mentions(current_user)) > 0
        .post-count.mentions= mentions
      =link_to format_title(channel), channel_path(channel), :class => "channel-link"

%br/
%br/
=will_paginate @recent_channels, :params => {:controller => "channels", :action => "index"}

Handle no last_post for channel
Handle no last_post for channel
