Fix empty search results bug
This commit is contained in:
1 parent
aebdc579a9
commit
8e03ca0ea6
5 files changed
+31
-6
No files matched your search
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- When a video error dialog shows, a timer with 10 seconds starts to play the next video
|
||||
|
||||
### Fixed
|
||||
|
||||
- A bug where the loading screen does not disappear if search results are empty.
|
||||
|
||||
## [0.20.2] - 2024-02-26
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||
import "pkg:/components/Navigation/Navigation.bs"
|
||||
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
|
||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||
@@ -203,8 +204,6 @@ end function
|
||||
|
||||
function Search(text as string)
|
||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||
' TODO:P1 someContentReady only fires if there are search results.
|
||||
' The case where search results are empty is not handled.
|
||||
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
|
||||
ShowLoadingScreen()
|
||||
|
||||
@@ -238,10 +237,16 @@ function Search(text as string)
|
||||
end function
|
||||
|
||||
function OnSearchContentReady() as void
|
||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||
|
||||
if not m.rowlist.someContentReady
|
||||
DialogUtils.ShowDialog("We didn't find any results for your search. Please try again with a different query or different filters.", "No results found")
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
return
|
||||
end if
|
||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||
|
||||
m.rowlist.focusable = true
|
||||
m.currentNavigtionNode = m.rowList
|
||||
NodeSetFocus(m.rowlist, true)
|
||||
@@ -253,6 +258,7 @@ function OnSearchContentReady() as void
|
||||
end function
|
||||
|
||||
function OnSearchError()
|
||||
' Note: we don't display an error dialog, VideoRowListRowContentTask will do that.
|
||||
m.rowlist.feeds = invalid
|
||||
m.rowlist.focusable = false
|
||||
HideLoadingScreen()
|
||||
|
||||
@@ -218,7 +218,6 @@ end function
|
||||
|
||||
function InitContent() as void
|
||||
CancelCurrentTasks()
|
||||
m.top.someContentReady = false
|
||||
|
||||
if m.top.feeds = invalid
|
||||
m.top.content = invalid
|
||||
|
||||
@@ -6,7 +6,13 @@
|
||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||
<field id="screen" type="node" />
|
||||
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
||||
<field id="someContentReady" type="bool" />
|
||||
<!--
|
||||
someContentReady is a field specifically for the search screen.
|
||||
It is set to true when there are some search results
|
||||
and set to false when there are no search results.
|
||||
It a signal to make sure to hide the loading indicator.
|
||||
-->
|
||||
<field id="someContentReady" type="bool" alwaysNotify="true" />
|
||||
<field id="onError" type="string" alwaysNotify="true" />
|
||||
<function name="OpenPlaylist" />
|
||||
<function name="OpenChannel" />
|
||||
|
||||
@@ -14,6 +14,8 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
|
||||
totalfetchedItems = 0
|
||||
|
||||
someContentReadySet = false
|
||||
|
||||
while true
|
||||
if m.top.cancel
|
||||
feedContentNode.loadState = FeedLoadState.None
|
||||
@@ -25,6 +27,10 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
|
||||
if feedSourcesIndex >= feedSources.Count()
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
|
||||
if not someContentReadySet
|
||||
rowList.someContentReady = false
|
||||
end if
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
@@ -36,6 +42,9 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
feedSourcesIndex += 1
|
||||
if feedSourcesIndex >= feedSources.Count()
|
||||
feedContentNode.loadState = FeedLoadState.Loaded
|
||||
if not someContentReadySet
|
||||
rowList.someContentReady = false
|
||||
end if
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
@@ -130,7 +139,8 @@ function VideoRowListRowContentTask(input as object) as object
|
||||
feedContentNode.loadState = FeedLoadState.LoadedPage
|
||||
end if
|
||||
|
||||
if itemNodes.Count() > 0
|
||||
if itemNodes.Count() > 0 and not someContentReadySet
|
||||
someContentReadySet = true
|
||||
rowList.someContentReady = true
|
||||
end if
|
||||
|
||||
|
||||
Reference in new issue
Block a user