From 4eda9edb0bc2cd2046d892124b194bde9a034a78 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 1 Oct 2024 11:35:09 -0400 Subject: [PATCH] validate data from api to prevent crash when refreshing movie detail screen --- source/Main.bs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/Main.bs b/source/Main.bs index 33c3ba85..c449601f 100644 --- a/source/Main.bs +++ b/source/Main.bs @@ -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) + 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) - ' 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) + ' 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()