don't use optional chaining operators + address review comments
This commit is contained in:
parent
742c60b910
commit
33c3894638
|
@ -257,11 +257,9 @@ sub Main (args as dynamic) as void
|
|||
ptr = msg.getData()
|
||||
' ptr is for [row, col] of selected item... but we only have 1 row
|
||||
series = msg.getRoSGNode()
|
||||
if isValid(ptr) and isValid(series?.seasonData?.items)
|
||||
if isValid(ptr) and ptr.count() >= 2 and isValid(ptr[1]) and isValid(series) and isValid(series.seasonData) and isValid(series.seasonData.items)
|
||||
node = series.seasonData.items[ptr[1]]
|
||||
group = CreateSeasonDetailsGroup(series.itemContent, node)
|
||||
else
|
||||
print "Something went wrong", ptr, series
|
||||
end if
|
||||
else if isNodeEvent(msg, "musicAlbumSelected")
|
||||
' If you select a Music Album from ANYWHERE, follow this flow
|
||||
|
@ -410,13 +408,13 @@ sub Main (args as dynamic) as void
|
|||
|
||||
' Check if a specific Audio Stream was selected
|
||||
audio_stream_idx = 1
|
||||
if isValid(group?.selectedAudioStreamIndex)
|
||||
if isValid(group) and isValid(group.selectedAudioStreamIndex)
|
||||
audio_stream_idx = group.selectedAudioStreamIndex
|
||||
end if
|
||||
|
||||
' Check to see if a specific video "version" was selected
|
||||
mediaSourceId = invalid
|
||||
if isValid(group?.selectedVideoStreamId)
|
||||
if isValid(group) and isValid(group.selectedVideoStreamId)
|
||||
mediaSourceId = group.selectedVideoStreamId
|
||||
end if
|
||||
video_id = group.id
|
||||
|
@ -425,14 +423,14 @@ sub Main (args as dynamic) as void
|
|||
sceneManager.callFunc("pushScene", video)
|
||||
end if
|
||||
|
||||
if isValid(group?.lastFocus?.id) = "main_group"
|
||||
if isValid(group) and isValid(group.lastFocus) and isValid(group.lastFocus.id) and group.lastFocus.id = "main_group"
|
||||
buttons = group.findNode("buttons")
|
||||
if isValid(buttons)
|
||||
group.lastFocus = group.findNode("buttons")
|
||||
end if
|
||||
end if
|
||||
|
||||
if isValid(group?.lastFocus)
|
||||
if isValid(group) and isValid(group.lastFocus)
|
||||
group.lastFocus.setFocus(true)
|
||||
end if
|
||||
|
||||
|
@ -447,7 +445,7 @@ sub Main (args as dynamic) as void
|
|||
trailerData = api_API().users.getlocaltrailers(get_setting("active_user"), group.id)
|
||||
video = invalid
|
||||
|
||||
if isValid(trailerData[0]?.id)
|
||||
if isValid(trailerData) and isValid(trailerData[0]) and isValid(trailerData[0].id)
|
||||
video_id = trailerData[0].id
|
||||
video = CreateVideoPlayerGroup(video_id, mediaSourceId, audio_stream_idx, false, false)
|
||||
end if
|
||||
|
@ -457,12 +455,12 @@ sub Main (args as dynamic) as void
|
|||
dialog.close = true
|
||||
end if
|
||||
|
||||
if isValid(group?.lastFocus)
|
||||
if isValid(group) and isValid(group.lastFocus)
|
||||
group.lastFocus.setFocus(true)
|
||||
end if
|
||||
else if btn <> invalid and btn.id = "watched-button"
|
||||
movie = group.itemContent
|
||||
if isValid(movie?.watched) and isValid(movie?.id)
|
||||
if isValid(movie) and isValid(movie.watched) and isValid(movie.id)
|
||||
if movie.watched
|
||||
UnmarkItemWatched(movie.id)
|
||||
else
|
||||
|
@ -489,11 +487,11 @@ sub Main (args as dynamic) as void
|
|||
else if isNodeEvent(msg, "optionSelected")
|
||||
button = msg.getRoSGNode()
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if button.id = "goto_search"
|
||||
if button.id = "goto_search" and isValid(group)
|
||||
' Exit out of the side panel
|
||||
panel = group.findNode("options")
|
||||
panel.visible = false
|
||||
if isValid(group?.lastFocus)
|
||||
if isValid(group.lastFocus)
|
||||
group.lastFocus.setFocus(true)
|
||||
else
|
||||
group.setFocus(true)
|
||||
|
@ -516,7 +514,7 @@ sub Main (args as dynamic) as void
|
|||
' Exit out of the side panel
|
||||
panel = group.findNode("options")
|
||||
panel.visible = false
|
||||
if isValid(group?.lastFocus)
|
||||
if isValid(group) and isValid(group.lastFocus)
|
||||
group.lastFocus.setFocus(true)
|
||||
else
|
||||
group.setFocus(true)
|
||||
|
@ -539,7 +537,7 @@ sub Main (args as dynamic) as void
|
|||
end if
|
||||
else if isNodeEvent(msg, "state")
|
||||
node = msg.getRoSGNode()
|
||||
if isValid(node?.state)
|
||||
if isValid(node) and isValid(node.state)
|
||||
if m.selectedItemType = "TvChannel" and node.state = "finished"
|
||||
video = CreateVideoPlayerGroup(node.id)
|
||||
m.global.sceneManager.callFunc("pushScene", video)
|
||||
|
@ -551,10 +549,10 @@ sub Main (args as dynamic) as void
|
|||
if isValid(node.retryWithTranscoding) and node.retryWithTranscoding
|
||||
retryVideo = CreateVideoPlayerGroup(node.Id, invalid, node.audioIndex, true, false)
|
||||
m.global.sceneManager.callFunc("popScene")
|
||||
if retryVideo <> invalid
|
||||
if isValid(retryVideo)
|
||||
m.global.sceneManager.callFunc("pushScene", retryVideo)
|
||||
end if
|
||||
else if isValid(node?.showID)
|
||||
else if not isValid(node.showID)
|
||||
sceneManager.callFunc("popScene")
|
||||
else
|
||||
if video.errorMsg = ""
|
||||
|
@ -571,7 +569,7 @@ sub Main (args as dynamic) as void
|
|||
if event.exitedScreensaver = true
|
||||
sceneManager.callFunc("resetTime")
|
||||
group = sceneManager.callFunc("getActiveScene")
|
||||
if isValid(group?.subtype())
|
||||
if isValid(group) and isValid(group.subtype())
|
||||
if group.subtype() = "Home"
|
||||
currentTime = CreateObject("roDateTime").AsSeconds()
|
||||
group.timeLastRefresh = currentTime
|
||||
|
|
Loading…
Reference in New Issue
Block a user