hummingbird-me/kitsu-web

View on GitHub
app/templates/components/application/user-notifications/item.hbs

Summary

Maintainability
Test Coverage
{{! guard due to development environments hitting shared stream }}
{{#if activity.actor}}
  <a href={{link}} class="media {{if (not group.isRead) "new"}}">
    <span class="media-left" href="#">
      {{#if isUser}}
        <img class="avatar-image avatar-image--small" src={{image activity.actor.avatar "small"}}>
      {{else}}
        <img class="poster-image" src={{image activity.actor.posterImage "small"}}>
      {{/if}}
    </span>
    <div class="media-body">
      <p class="media-heading">
        {{#if isUser}}
          <a href={{href-to "users.index" activity.actor}}>{{activity.actor.name}}</a>
          {{! more than one? }}
          {{#if (gt others.length 0)}}
            {{#if (eq others.length 1)}}
              {{#with (get others "firstObject") as |other|}}
                {{#if other.actor}}
                  and <a href={{href-to "users.index" other.actor}}>{{other.actor.name}}</a>
                {{else}}
                  and Unknown.
                {{/if}}
              {{/with}}
            {{else}}
              and <strong>{{otherCount}} others</strong>
            {{/if}}
          {{/if}}
        {{/if}}

        {{! type }}
        {{! TODO(@vevix): Refactor to be better }}
        {{#if (eq activity.verb "follow")}}
          followed you.
        {{else if (eq activity.verb "post")}}
          mentioned you in a post.
        {{else if (eq activity.verb "comment")}}
          {{#if (eq session.account.id (split-stream-id activity.replyToUser))}}
            replied to your
            {{#if (eq activity.replyToType "comment")}}
              comment.
            {{else}}
              post.
            {{/if}}
          {{else if isMentioned}}
            mentioned you in a comment.
          {{else}}
            replied to
            {{#if (and activity.target activity.target.user)}}
              {{#if (eq activity.target.user.id activity.actor.id)}}
                their
              {{else if (eq activity.target.user.id session.account.id)}}
                your
              {{else}}
                <a href={{href-to "users.index" activity.target.user}}>{{activity.target.user.name}}'s</a>
              {{/if}}
            {{else}}
              a
            {{/if}}
            post.
          {{/if}}
        {{else if (eq activity.verb "post_like")}}
          liked your post.
        {{else if (eq activity.verb "comment_like")}}
          liked your comment.
        {{else if (eq activity.verb "invited")}}
          invited you to a group.
        {{else if (eq activity.verb "vote")}}
          liked your {{activity.target.media.computedTitle}} reaction.
        {{else if (eq activity.verb "aired")}}
          {{#if (and activity.subject (gt activity.subject.number 0))}}
            {{t "user-notifications.aired" type=activity.subject.modelType number=activity.subject.number media=activity.actor.computedTitle}}
          {{else}}
            {{t "user-notifications.aired-unknown" type=activity.actor.modelType media=activity.actor.computedTitle}}
          {{/if}}
        {{/if}}
      </p>
      <small class="media-secondary">{{moment-from-now activity.time interval=60000}}</small>
    </div>
  </a>
{{/if}}