From b3ee484220700ce66358bafe3c0c25ad08f96543 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:40:44 -0500 Subject: [PATCH] Add valid checks to used variables Creates new helper function - isAllValid() --- components/extras/ExtrasRowList.bs | 11 +++++++++-- source/utils/misc.bs | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/extras/ExtrasRowList.bs b/components/extras/ExtrasRowList.bs index 3c2d9308..70b886c3 100644 --- a/components/extras/ExtrasRowList.bs +++ b/components/extras/ExtrasRowList.bs @@ -1,3 +1,5 @@ +import "pkg:/source/utils/misc.bs" + sub init() m.top.visible = true updateSize() @@ -184,8 +186,13 @@ function buildRow(rowTitle as string, items, imgWdth = 0) row.Title = tr(rowTitle) for each mov in items if LCase(mov.json.type) = "episode" - mov.labelText = mov.json.SeriesName - mov.subTitle = `S${mov.json.ParentIndexNumber}:E${mov.json.IndexNumber} - ${mov.json.Name}` + if isAllValid([mov.json.SeriesName, mov.json.ParentIndexNumber, mov.json.IndexNumber, mov.json.Name]) + mov.labelText = mov.json.SeriesName + mov.subTitle = `S${mov.json.ParentIndexNumber}:E${mov.json.IndexNumber} - ${mov.json.Name}` + else + mov.labelText = mov.json.Name + mov.subTitle = mov.json.ProductionYear + end if else mov.labelText = mov.json.Name mov.subTitle = mov.json.ProductionYear diff --git a/source/utils/misc.bs b/source/utils/misc.bs index 7cd621f4..49c84bfb 100644 --- a/source/utils/misc.bs +++ b/source/utils/misc.bs @@ -299,6 +299,14 @@ function isValid(input as dynamic) as boolean return input <> invalid end function +' Returns whether or not all items in passed array are valid +function isAllValid(input as object) as boolean + for each item in input + if not isValid(item) then return false + end for + return true +end function + ' Returns whether or not passed value is valid and not empty ' Accepts a string, or any countable type (arrays and lists) function isValidAndNotEmpty(input as dynamic) as boolean