From 388bd0a371b7c3b21a8c153e0766166c690e4ad1 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sat, 18 Nov 2023 09:38:36 -0500 Subject: [PATCH 1/2] fix episode list bug where OK was triggering quickplay --- components/tvshows/TVEpisodes.bs | 55 ++++++++++++++++++++----------- components/tvshows/TVEpisodes.xml | 1 + source/ShowScenes.bs | 2 +- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/components/tvshows/TVEpisodes.bs b/components/tvshows/TVEpisodes.bs index 583e4d30..f820357d 100644 --- a/components/tvshows/TVEpisodes.bs +++ b/components/tvshows/TVEpisodes.bs @@ -46,10 +46,28 @@ sub updateSeason() m.top.overhangTitle = m.top.seasonData.SeriesName + " - " + m.top.seasonData.name end sub +' get the currently focused item +function getFocusedItem() as dynamic + if isValid(m.top.focusedChild) and isValid(m.top.focusedChild.focusedChild) + focusedChild = m.top.focusedChild.focusedChild + if not isValid(focusedChild.content) then return invalid + m.top.lastFocus = focusedChild + else + return invalid + end if + + if isValidAndNotEmpty(focusedChild.rowItemFocused) + itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) + if isValid(itemToPlay) and isValidAndNotEmpty(itemToPlay.id) + return itemToPlay + end if + end if + + return invalid +end function + ' Handle navigation input from the remote and act on it function onKeyEvent(key as string, press as boolean) as boolean - handled = false - if key = "left" and m.tvEpisodeRow.hasFocus() m.shuffle.setFocus(true) return true @@ -70,7 +88,15 @@ function onKeyEvent(key as string, press as boolean) as boolean return true end if - if key = "OK" or key = "play" + if key = "OK" + if m.tvEpisodeRow.isInFocusChain() + focusedItem = getFocusedItem() + if isValid(focusedItem) + m.top.selectedItem = focusedItem + end if + return true + end if + if m.shuffle.hasFocus() episodeList = m.rows.getChild(0).objects.items @@ -97,22 +123,13 @@ function onKeyEvent(key as string, press as boolean) as boolean end if end if - focusedChild = m.top.focusedChild.focusedChild - if focusedChild.content = invalid then return handled - - ' OK needs to be handled on release... - proceed = false - if key = "OK" - proceed = true - end if - - if press and key = "play" or proceed = true - m.top.lastFocus = focusedChild - itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) - if isValid(itemToPlay) and isValid(itemToPlay.id) and itemToPlay.id <> "" - m.top.quickPlayNode = itemToPlay + if key = "play" + focusedItem = getFocusedItem() + if isValid(focusedItem) + m.top.quickPlayNode = focusedItem end if - handled = true + return true end if - return handled + + return false end function diff --git a/components/tvshows/TVEpisodes.xml b/components/tvshows/TVEpisodes.xml index ec2dd952..84d26f5d 100644 --- a/components/tvshows/TVEpisodes.xml +++ b/components/tvshows/TVEpisodes.xml @@ -12,6 +12,7 @@ + diff --git a/source/ShowScenes.bs b/source/ShowScenes.bs index dca7b2b2..4f301b7c 100644 --- a/source/ShowScenes.bs +++ b/source/ShowScenes.bs @@ -790,7 +790,7 @@ function CreateSeasonDetailsGroup(series as object, season as object) as dynamic group.extrasObjects = TVSeasonExtras(season.id) ' watch for button presses - group.observeField("episodeSelected", m.port) + group.observeField("selectedItem", m.port) group.observeField("quickPlayNode", m.port) ' finished building SeasonDetails view stopLoadingSpinner() From 491ef43fd5347178b99db7a54d10c3407af88bc5 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Sun, 19 Nov 2023 22:04:17 -0500 Subject: [PATCH 2/2] refactor to remove else clause --- components/tvshows/TVEpisodes.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/tvshows/TVEpisodes.bs b/components/tvshows/TVEpisodes.bs index f820357d..ffc225cd 100644 --- a/components/tvshows/TVEpisodes.bs +++ b/components/tvshows/TVEpisodes.bs @@ -48,14 +48,14 @@ end sub ' get the currently focused item function getFocusedItem() as dynamic - if isValid(m.top.focusedChild) and isValid(m.top.focusedChild.focusedChild) - focusedChild = m.top.focusedChild.focusedChild - if not isValid(focusedChild.content) then return invalid - m.top.lastFocus = focusedChild - else + if not isValid(m.top.focusedChild) or not isValid(m.top.focusedChild.focusedChild) return invalid end if + focusedChild = m.top.focusedChild.focusedChild + if not isValid(focusedChild.content) then return invalid + m.top.lastFocus = focusedChild + if isValidAndNotEmpty(focusedChild.rowItemFocused) itemToPlay = focusedChild.content.getChild(focusedChild.rowItemFocused[0]).getChild(0) if isValid(itemToPlay) and isValidAndNotEmpty(itemToPlay.id)