Add valid checks to used variables
Creates new helper function - isAllValid()
This commit is contained in:
parent
3811f298d3
commit
b3ee484220
|
@ -1,3 +1,5 @@
|
||||||
|
import "pkg:/source/utils/misc.bs"
|
||||||
|
|
||||||
sub init()
|
sub init()
|
||||||
m.top.visible = true
|
m.top.visible = true
|
||||||
updateSize()
|
updateSize()
|
||||||
|
@ -184,12 +186,17 @@ function buildRow(rowTitle as string, items, imgWdth = 0)
|
||||||
row.Title = tr(rowTitle)
|
row.Title = tr(rowTitle)
|
||||||
for each mov in items
|
for each mov in items
|
||||||
if LCase(mov.json.type) = "episode"
|
if LCase(mov.json.type) = "episode"
|
||||||
|
if isAllValid([mov.json.SeriesName, mov.json.ParentIndexNumber, mov.json.IndexNumber, mov.json.Name])
|
||||||
mov.labelText = mov.json.SeriesName
|
mov.labelText = mov.json.SeriesName
|
||||||
mov.subTitle = `S${mov.json.ParentIndexNumber}:E${mov.json.IndexNumber} - ${mov.json.Name}`
|
mov.subTitle = `S${mov.json.ParentIndexNumber}:E${mov.json.IndexNumber} - ${mov.json.Name}`
|
||||||
else
|
else
|
||||||
mov.labelText = mov.json.Name
|
mov.labelText = mov.json.Name
|
||||||
mov.subTitle = mov.json.ProductionYear
|
mov.subTitle = mov.json.ProductionYear
|
||||||
end if
|
end if
|
||||||
|
else
|
||||||
|
mov.labelText = mov.json.Name
|
||||||
|
mov.subTitle = mov.json.ProductionYear
|
||||||
|
end if
|
||||||
|
|
||||||
mov.Id = mov.json.Id
|
mov.Id = mov.json.Id
|
||||||
mov.Type = mov.json.Type
|
mov.Type = mov.json.Type
|
||||||
|
|
|
@ -299,6 +299,14 @@ function isValid(input as dynamic) as boolean
|
||||||
return input <> invalid
|
return input <> invalid
|
||||||
end function
|
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
|
' Returns whether or not passed value is valid and not empty
|
||||||
' Accepts a string, or any countable type (arrays and lists)
|
' Accepts a string, or any countable type (arrays and lists)
|
||||||
function isValidAndNotEmpty(input as dynamic) as boolean
|
function isValidAndNotEmpty(input as dynamic) as boolean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user