jf-roku/components/liveTv/LoadProgramDetailsTask.bs

45 lines
1.2 KiB
Plaintext
Raw Normal View History

import "pkg:/source/api/baserequest.bs"
import "pkg:/source/utils/config.bs"
2020-11-23 17:13:57 +00:00
sub init()
m.top.functionName = "loadProgramDetails"
2021-07-09 20:08:32 +00:00
2020-11-23 17:13:57 +00:00
end sub
sub loadProgramDetails()
channelIndex = m.top.ChannelIndex
programIndex = m.top.ProgramIndex
params = {
UserId: m.global.session.user.id
2020-11-23 17:13:57 +00:00
}
url = Substitute("LiveTv/Programs/{0}", m.top.programId)
resp = APIRequest(url, params)
data = getJson(resp)
if data = invalid
2020-11-23 17:13:57 +00:00
m.top.programDetails = {}
return
end if
program = createObject("roSGNode", "ScheduleProgramData")
program.json = data
program.channelIndex = channelIndex
program.programIndex = programIndex
2020-11-23 17:13:57 +00:00
program.fullyLoaded = true
' Are we currently recording this program?
2022-01-09 14:56:52 +00:00
if program.json.TimerId <> invalid and program.json.TimerId <> ""
' This is needed here because the callee (onProgramDetailsLoaded) replaces the grid item with
' this newly created item from the server, without this, the red icon
2022-01-09 05:50:53 +00:00
' disappears when the user focuses on the program in question
program.hdSmallIconUrl = "pkg:/images/red.png"
2022-01-09 14:56:10 +00:00
else
program.hdSmallIconUrl = invalid
end if
2020-11-23 17:13:57 +00:00
m.top.programDetails = program
2022-05-30 12:57:40 +00:00
end sub