hummingbird-me/kitsu-web

View on GitHub
app/templates/components/stream-feed/list.hbs

Summary

Maintainability
Test Coverage
{{#unless hidePostEditor}}
  {{stream-feed/create-post
    readOnly=readOnly
    placeholder=(t "feeds.placeholder" subject=subject type=(if (and (eq streamType "user_aggr") (is-self user)) "" streamType))
    media=media
    unitNumber=unitNumber
    forceUnit=forceUnit
    forceNsfw=(readonly showNsfw)
    nsfw=(readonly showNsfw)
    user=user
    onCreate=(perform createPost)
  }}
{{else if (and kitsuGroup kitsuGroup.isRestricted)}}
  <div class="card m-b-2">
    <div class="card-block text-xs-center">
      {{t "groups.activity.feed-restricted"}}
    </div>
  </div>
{{/unless}}

<div class="feed-actions clearfix {{if hidePostEditor "is-hidden"}}">
  {{! new activities block }}
  {{#if (gt newItems.length 0)}}
    <div class="card text-xs-center p-t-1 p-b-1" {{action "newActivities"}}>
      {{#if realtimeLoading}}
        {{loading-spinner size="small"}}
      {{else}}
        {{pluralize newItems.length "new activity"}}
      {{/if}}
    </div>
  {{/if}}

  {{! custom block (used on dashboard for switching feeds }}
  {{#if hasBlock}}
    {{yield}}
  {{/if}}

  {{! feed content type filter }}
  {{#unless (or kitsuGroup hideFilter)}}
  <div class="pull-sm-right feed-filter">
    {{#bootstrap/bs-dropdown as |dropdown|}}
      {{#dropdown.button}}
        {{t (concat "feeds.filter." filter)}}
      {{/dropdown.button}}
      {{#dropdown.menu}}
        {{#each filterOptions as |option|}}
          {{#dropdown.menu-item onClick=(action "updateFilter" option)}}
            {{t (concat "feeds.filter." option)}}
            {{#if (eq option filter)}}
              <span class="dropdown-checkmark">{{svg-jar "checkmark"}}</span>
            {{/if}}
          {{/dropdown.menu-item}}
        {{/each}}
      {{/dropdown.menu}}
    {{/bootstrap/bs-dropdown}}
  </div>
  {{/unless}}
</div>

{{! Interest Notice }}
{{#if (and showInterestNotice (eq streamType "interest_timeline"))}}
  <div class="interest-notice card">
    <aside>
      {{svg-jar streamInterest}}
    </aside>
    <article>
      <h5>{{t (concat "feeds.interest." streamInterest ".header")}}</h5>
      <p>
        {{t (concat "feeds.interest." streamInterest ".body") link=(href-to "users.library" session.account (query-params media=streamInterest)) htmlSafe=true}}
      </p>
    </article>
    <button type="button" class="button button--primary" onclick={{action "dismissNotice"}}>
      {{t "feeds.interest.button"}}
    </button>
    <button type="button" class="close" onclick={{action "dismissNotice"}}>
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
{{/if}}

{{#if (and getFeedData.isRunning (not realtimeLoading))}}
  {{#each (repeat 2) as |empty|}}
    <div class="stream-item stream-item--loading row">
      <div class="stream-item-wrapper col-sm-12">
        <div class='panel-effect'>
          <div class='fake-effect fe-0'></div>
          <div class='fake-effect fe-1'></div>
          <div class='fake-effect fe-2'></div>
          <div class='fake-effect fe-3'></div>
          <div class='fake-effect fe-4'></div>
          <div class='fake-effect fe-5'></div>
          <div class='fake-effect fe-6'></div>
          <div class='fake-effect fe-7'></div>
          <div class='fake-effect fe-8'></div>
          <div class='fake-effect fe-9'></div>
          <div class='fake-effect fe-10'></div>
          <div class='fake-effect fe-11'></div>
          <div class='fake-effect fe-12'></div>
          <div class='fake-effect fe-13'></div>
        </div>
      </div>
    </div>
  {{/each}}
{{else}}
  {{! Pinned Post }}
  {{#if pinned}}
    {{stream-feed/items/post
      post=pinned.content
      readOnly=(not session.hasUser)
      isPinnedPost=true
    }}
  {{/if}}

  {{! feed items }}
  {{#infinite-pagination rootMargin=(hash bottom=400) onPagination=(action "onPagination")}}
    {{#each allFeedItems as |group index|}}
      {{#if group.activities.length}}
        {{#occludable-area rootMargin=(hash bottom=200) bufferClass="feed-occlusion-buffer"}}
          {{component (concat "stream-feed/items/" (feed-type group.activities))
            group=group
            feedId=feedId
            showNsfw=showNsfw
            showSpoilers=(eq streamType "interest_timeline")
            canHide=(and (eq streamType "timeline") (eq (feed-type group.activities) "post"))
            canHideMedia=(and (eq streamType "interest_timeline") (eq (feed-type group.activities) "post"))
            positionInFeed=index
            readOnly=readOnly
            kitsuGroup=kitsuGroup
            kitsuGroupMembership=kitsuGroupMembership
            removeGroup=(action "removeGroup")
            deleteActivity=(action "deleteActivity")
          }}
        {{/occludable-area}}
      {{/if}}

      {{! ads inserted }}
      {{#if (is-multiple-of (inc index) 10)}}
        {{#if (and kitsuGroup kitsuGroup.nsfw)}}
          {{! ... }}
        {{else if (and media media.nsfw)}}
          {{! ... }}
        {{else}}
          {{ad-unit
            unit="kitsu.feeds.inline"
            targeting=(hash section="feed")
            sizes=(hash
              mobile=(array (array 336 280) (array 300 250) (array 320 100) (array 320 50))
            )
          }}
        {{/if}}
      {{/if}}
    {{else}}
      <div class="stream-error-wrapper col-sm-12">
        {{t "errors.contentEmpty"}}
      </div>
    {{/each}}
  {{/infinite-pagination}}
{{/if}}