From a51a75b8cd67a692b06eeec2ef259f605322c23a Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Tue, 1 Oct 2024 09:29:52 -0400 Subject: [PATCH] validate node refs to prevent crash --- components/home/HomeItem.bs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/components/home/HomeItem.bs b/components/home/HomeItem.bs index 797e253c1..6be223fb8 100644 --- a/components/home/HomeItem.bs +++ b/components/home/HomeItem.bs @@ -10,12 +10,12 @@ sub init() initItemPoster() m.itemProgress = m.top.findNode("progress") m.itemProgressBackground = m.top.findNode("progressBackground") - m.itemIcon = m.top.findNode("itemIcon") + initItemIcon() initItemTextExtra() m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged") m.unplayedCount = m.top.findNode("unplayedCount") m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount") - m.playedIndicator = m.top.findNode("playedIndicator") + initPlayedIndicator() m.showProgressBarAnimation = m.top.findNode("showProgressBar") m.showProgressBarField = m.top.findNode("showProgressBarField") @@ -50,6 +50,14 @@ sub initBackdrop() m.backdrop = m.top.findNode("backdrop") end sub +sub initItemIcon() + m.itemIcon = m.top.findNode("itemIcon") +end sub + +sub initPlayedIndicator() + m.playedIndicator = m.top.findNode("playedIndicator") +end sub + sub itemContentChanged() if isValid(m.unplayedCount) then m.unplayedCount.visible = false itemData = m.top.itemContent @@ -63,6 +71,8 @@ sub itemContentChanged() if not isValid(m.itemText) then initItemText() if not isValid(m.itemTextExtra) then initItemTextExtra() if not isValid(m.backdrop) then initBackdrop() + if not isValid(m.itemIcon) then initItemIcon() + if not isValid(m.playedIndicator) then initPlayedIndicator() m.itemPoster.width = itemData.imageWidth m.itemText.maxWidth = itemData.imageWidth @@ -87,7 +97,9 @@ sub itemContentChanged() if isValid(itemData.json.UserData) and isValid(itemData.json.UserData.UnplayedItemCount) if itemData.json.UserData.UnplayedItemCount > 0 if isValid(m.unplayedCount) then m.unplayedCount.visible = true - m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + if isValid(m.unplayedEpisodeCount) + m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + end if end if end if end if