Skip to content

Commit

Permalink
Add more defensive coding to home items
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Nov 7, 2024
1 parent b4acde2 commit bfa5162
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions components/home/HomeItem.bs
Original file line number Diff line number Diff line change
Expand Up @@ -350,46 +350,52 @@ sub displayProgramInfo(itemData as object)
end sub

sub displayEpisodeInfo(localGlobal as object, itemData as object)
m.itemText.text = itemData.json.SeriesName
if isChainValid(itemData, "json.SeriesName")
m.itemText.text = itemData.json.SeriesName
end if

if itemData.PlayedPercentage > 0
drawProgressBar(itemData)
if isValid(itemData.LookupCI("PlayedPercentage"))
if itemData.LookupCI("PlayedPercentage") > 0
drawProgressBar(itemData)
end if
end if

if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "webclient"
tmpSetting = localGlobal.session.user.Configuration.useEpisodeImagesInNextUpAndResume
if isValid(tmpSetting) and tmpSetting
m.itemPoster.uri = itemData.thumbnailURL
m.itemPoster.uri = itemData.LookupCI("thumbnailURL")
else
m.itemPoster.uri = itemData.widePosterURL
m.itemPoster.uri = itemData.LookupCI("widePosterURL")
end if
else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "show"
m.itemPoster.uri = itemData.widePosterURL
m.itemPoster.uri = itemData.LookupCI("widePosterURL")
else if localGlobal.session.user.settings["ui.general.episodeimagesnextup"] = "episode"
m.itemPoster.uri = itemData.thumbnailURL
m.itemPoster.uri = itemData.LookupCI("thumbnailURL")
end if

' Set Series and Episode Number for Extra Text
extraPrefix = ""
if isValid(itemData.json.ParentIndexNumber)
if isChainValid(itemData, "json.ParentIndexNumber")
extraPrefix = "S" + StrI(itemData.json.ParentIndexNumber).trim()
end if

if isValid(itemData.json.IndexNumber)
if isChainValid(itemData, "json.IndexNumber")
extraPrefix = extraPrefix + "E" + StrI(itemData.json.IndexNumber).trim()
end if

if extraPrefix.len() > 0
extraPrefix = extraPrefix + " - "
end if

m.itemTextExtra.text = extraPrefix + itemData.name
m.itemTextExtra.text = extraPrefix + itemData.LookupCI("name")
end sub

'
' Draws and animates item progress bar
sub drawProgressBar(itemData)
m.itemProgressBackground.width = itemData.imageWidth
if not isValid(itemData.LookupCI("imageWidth")) then return

m.itemProgressBackground.width = itemData.LookupCI("imageWidth")
m.itemProgressBackground.visible = true
m.showProgressBarField.keyValue = [0, m.itemPoster.width * (itemData.PlayedPercentage / 100)]
m.showProgressBarAnimation.control = AnimationControl.START
Expand Down

0 comments on commit bfa5162

Please sign in to comment.