Skip to content

Commit

Permalink
validate data from api to prevent crash when refreshing movie detail …
Browse files Browse the repository at this point in the history
…screen
  • Loading branch information
cewert committed Oct 1, 2024
1 parent d7c99f5 commit 4eda9ed
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,19 @@ sub Main (args as dynamic) as void
currentScene = m.global.sceneManager.callFunc("getActiveScene")

if isValid(currentScene) and isValid(currentScene.itemContent) and isValid(currentScene.itemContent.id)
' Refresh movie detail data
currentScene.itemContent.json = api.users.GetItem(m.global.session.user.id, currentScene.itemContent.id)
movieMetaData = ItemMetaData(currentScene.itemContent.id)

' Redraw movie poster
currentScene.newPosterImageURI = movieMetaData.posterURL

' Set updated starting point for the queue item
m.global.queueManager.callFunc("setTopStartingPoint", currentScene.itemContent.json.UserData.PlaybackPositionTicks)
data = api.users.GetItem(m.global.session.user.id, currentScene.itemContent.id)
if isValid(data)
currentScene.itemContent.json = data
' Set updated starting point for the queue item
m.global.queueManager.callFunc("setTopStartingPoint", data.UserData.PlaybackPositionTicks)

' Refresh movie detail data
movieMetaData = ItemMetaData(currentScene.itemContent.id)
if isValid(movieMetaData)
' Redraw movie poster
currentScene.newPosterImageURI = movieMetaData.posterURL
end if
end if
end if

stopLoadingSpinner()
Expand Down

0 comments on commit 4eda9ed

Please sign in to comment.