components_GetNextEpisodeTask.bs

import "pkg:/source/api/ApiClient.bs"
import "pkg:/source/api/apiPool.bs"
import "pkg:/source/utils/misc.bs"

sub init()
  m.top.functionName = "getNextEpisodeTask"
end sub

' Orchestrator Task: submits to ApiTask pool via queue and waits off the render thread.
sub getNextEpisodeTask()
  res = fetchRes(GetApi().BuildGetEpisodesRequest(m.top.showID, {
    StartItemId: m.top.videoID,
    Limit: 2
  }), "nextEpisode")
  if isValid(res) and res.ok
    m.top.nextEpisodeData = res.json
  end if
end sub