RowCell bug fix

This commit is contained in:
Brahim Hadriche committed 2023-11-08 08:18:45 -05:00
1 parent c1bb059d66
commit 38a1d9a950
3 files changed
+46 -19

No files matched your search

+4
View File
@@ -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
@@ -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
@@ -3,6 +3,20 @@
<field id="type" type="string" />
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="index" type="integer" />
<field id="videoRowCellVisible" type="boolean" alias="VideoRowCell.visible" />
<field id="playlistRowCellVisible" type="boolean" alias="PlaylistRowCell.visible" />
<field id="channelRowCellVisible" type="boolean" alias="ChannelRowCell.visible" />
<field id="loadingRowCellVisible" type="boolean" alias="LoadingRowCell.visible" />
<field id="actionRowCellVisible" type="boolean" alias="ActionRowCell.visible" />
<field id="videoRowCellItemContent" type="node" alias="VideoRowCell.itemContent" />
<field id="playlistRowCellItemContent" type="node" alias="PlaylistRowCell.itemContent" />
<field id="channelRowCellItemContent" type="node" alias="ChannelRowCell.itemContent" />
<field id="loadingRowCellItemContent" type="node" alias="LoadingRowCell.itemContent" />
<field id="actionRowCellItemContent" type="node" alias="ActionRowCell.itemContent" />
<field id="loadingRowCellIndex" type="integer" alias="LoadingRowCell.index" />
</interface>
<children>
<VideoRowCell id="VideoRowCell" />