diff --git a/CHANGELOG.md b/CHANGELOG.md index e8608c93..f9594ca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - An option to disable search history +### Fixed + +- A rare bug that causes the app to crash when displaying video cells + ## [0.15.0] - 2023-11-05 ### Added diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.bs b/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.bs index 478044f7..6e65e8b5 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.bs +++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.bs @@ -1,40 +1,49 @@ -function Init() - m.videoRowCell = m.top.findNode("VideoRowCell") - m.playlistRowCell = m.top.findNode("PlaylistRowCell") - m.channelRowCell = m.top.findNode("ChannelRowCell") - m.loadingRowCell = m.top.findNode("LoadingRowCell") - m.actionRowCell = m.top.findNode("ActionRowCell") - m.cells = [m.videoRowCell, m.playlistRowCell, m.channelRowCell, m.loadingRowCell, m.actionRowCell] -end function - +' Note: we use aliases and not references to sub cells that we initialize on Init() because +' of a rare bug / race condition where the cells are not initialized function OnContentSet() as void content = m.top.itemContent + visibleProperties = { + "video": "videoRowCellVisible", + "playlist": "playlistRowCellVisible", + "channel": "channelRowCellVisible", + "loading": "loadingRowCellVisible", + "action": "actionRowCellVisible" + } + + contentProperties = { + "video": "videoRowCellItemContent", + "playlist": "playlistRowCellItemContent", + "channel": "channelRowCellItemContent", + "loading": "loadingRowCellItemContent", + "action": "actionRowCellItemContent" + } + if content = invalid - for each cell in m.cells - cell.visible = false + for each key in visibleProperties + m.top[visibleProperties[key]] = false end for - m.loadingRowCell.visible = true + m.top.loadingRowCellVisible = true return end if m.top.type = content.type visibleSet = false - for each cell in m.cells - shouldBeVisible = content.type = cell.type - cell.visible = shouldBeVisible + for each key in visibleProperties + shouldBeVisible = content.type = key + m.top[visibleProperties[key]] = shouldBeVisible if shouldBeVisible - cell.itemContent = content + m.top[contentProperties[key]] = content visibleSet = true end if end for if not visibleSet - m.loadingRowCell.visible = true + m.top.loadingRowCellVisible = true end if - if m.loadingRowCell.visible - m.loadingRowCell.index = m.top.index + if m.top.loadingRowCellVisible + m.top.loadingRowCellIndex = m.top.index end if end function diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.xml b/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.xml index 8aa1f54a..55248595 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.xml +++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/RowCell.xml @@ -3,6 +3,20 @@ + + + + + + + + + + + + + +