extends includes/layout.pug

include includes/video-list-item.pug
include includes/toasts

block head
  title Subscriptions - EirTube
  script(type="module" src=getStaticURL("html", "/static/js/subscriptions.js"))
  - if (settings.dearrow > 0 && settings.dearrow_preload == 0)
    script const dearrow_thumbnail_instance = "!{settings.dearrow_thumbnail_instance}"
    script(video-class="subscriptions-video" src=getStaticURL("html", "/static/js/dearrow-load.js"))

block content
  main.subscriptions-page
    if hasSubscriptions
      section
        details.channels-details
          summary
            | #{channels.length} subscriptions
            if missingChannelCount === 1
              = ` - ${missingChannelCount} channel is gone`
            else if missingChannelCount > 1
              = ` - ${missingChannelCount} channels are gone`
          .channels-list
            for channel in channels
              a(href=`/channel/${channel.ucid}`).channel-item
                img(loading="lazy" src=channel.icon_url width=512 height=512 alt="").thumbnail
                div
                  div.name= channel.name
                  if channel.missing
                    div.missing-reason
                      if channel.missing_reason
                        = channel.missing_reason
                      else
                        | This channel appears to be deleted or terminated. Click to check it.

      if refreshed
        section
          details.channels-details
            summary Last refreshed #{timeToPastText(refreshed.min)}
            div Oldest channel was refreshed #{timeToPastText(refreshed.min)}
            div Newest channel was refreshed #{timeToPastText(refreshed.max)}
            - const notLoaded = channels.length - refreshed.count
            if notLoaded
              div #{notLoaded} subscriptions have not been refreshed at all
            div Your subscriptions will be regularly refreshed in the background if you have visited recently.

      if settings.save_history
        input(type="checkbox" id="watched-videos-display")
        .checkbox-hider__container
          label(for="watched-videos-display").checkbox-hider__label Hide watched videos

      each video in videos
        +video_list_item("subscriptions-video", video, { showMarkWatched: settings.save_history && !video.watched, settings: settings })
    else
      .no-subscriptions
        h2 You have no subscriptions.
        p Subscribing to a channel makes its videos appear here.
        p You can find the subscribe button on channels and videos.

  #toast-container
    each toast in toasts
      +toast(toast.color, toast.icon, toast.text)
