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
|
- 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
|
## [0.20.2] - 2024-02-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import "pkg:/components/Dialog/DialogUtils.bs"
|
||||||
import "pkg:/components/Navigation/Navigation.bs"
|
import "pkg:/components/Navigation/Navigation.bs"
|
||||||
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
|
import "pkg:/components/Services/SearchHistory/SearchHistoryUtils.bs"
|
||||||
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
import "pkg:/source/AsyncTask/AsyncTask.bs"
|
||||||
@@ -203,8 +204,6 @@ end function
|
|||||||
|
|
||||||
function Search(text as string)
|
function Search(text as string)
|
||||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
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))
|
m.rowlist.ObserveFieldScoped("someContentReady", FuncName(OnSearchContentReady))
|
||||||
ShowLoadingScreen()
|
ShowLoadingScreen()
|
||||||
|
|
||||||
@@ -238,10 +237,16 @@ function Search(text as string)
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function OnSearchContentReady() as void
|
function OnSearchContentReady() as void
|
||||||
|
m.rowlist.UnobserveFieldScoped("someContentReady")
|
||||||
|
|
||||||
if not m.rowlist.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
|
return
|
||||||
end if
|
end if
|
||||||
m.rowlist.UnobserveFieldScoped("someContentReady")
|
|
||||||
m.rowlist.focusable = true
|
m.rowlist.focusable = true
|
||||||
m.currentNavigtionNode = m.rowList
|
m.currentNavigtionNode = m.rowList
|
||||||
NodeSetFocus(m.rowlist, true)
|
NodeSetFocus(m.rowlist, true)
|
||||||
@@ -253,6 +258,7 @@ function OnSearchContentReady() as void
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
function OnSearchError()
|
function OnSearchError()
|
||||||
|
' Note: we don't display an error dialog, VideoRowListRowContentTask will do that.
|
||||||
m.rowlist.feeds = invalid
|
m.rowlist.feeds = invalid
|
||||||
m.rowlist.focusable = false
|
m.rowlist.focusable = false
|
||||||
HideLoadingScreen()
|
HideLoadingScreen()
|
||||||
|
|||||||
@@ -218,7 +218,6 @@ end function
|
|||||||
|
|
||||||
function InitContent() as void
|
function InitContent() as void
|
||||||
CancelCurrentTasks()
|
CancelCurrentTasks()
|
||||||
m.top.someContentReady = false
|
|
||||||
|
|
||||||
if m.top.feeds = invalid
|
if m.top.feeds = invalid
|
||||||
m.top.content = invalid
|
m.top.content = invalid
|
||||||
|
|||||||
@@ -6,7 +6,13 @@
|
|||||||
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
<field id="bookmarks" type="node" bind="/Bookmarks" />
|
||||||
<field id="screen" type="node" />
|
<field id="screen" type="node" />
|
||||||
<field id="feeds" type="array" onChange="OnFeedsChange" />
|
<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" />
|
<field id="onError" type="string" alwaysNotify="true" />
|
||||||
<function name="OpenPlaylist" />
|
<function name="OpenPlaylist" />
|
||||||
<function name="OpenChannel" />
|
<function name="OpenChannel" />
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ function VideoRowListRowContentTask(input as object) as object
|
|||||||
|
|
||||||
totalfetchedItems = 0
|
totalfetchedItems = 0
|
||||||
|
|
||||||
|
someContentReadySet = false
|
||||||
|
|
||||||
while true
|
while true
|
||||||
if m.top.cancel
|
if m.top.cancel
|
||||||
feedContentNode.loadState = FeedLoadState.None
|
feedContentNode.loadState = FeedLoadState.None
|
||||||
@@ -25,6 +27,10 @@ function VideoRowListRowContentTask(input as object) as object
|
|||||||
|
|
||||||
if feedSourcesIndex >= feedSources.Count()
|
if feedSourcesIndex >= feedSources.Count()
|
||||||
feedContentNode.loadState = FeedLoadState.Loaded
|
feedContentNode.loadState = FeedLoadState.Loaded
|
||||||
|
|
||||||
|
if not someContentReadySet
|
||||||
|
rowList.someContentReady = false
|
||||||
|
end if
|
||||||
return {
|
return {
|
||||||
success: true
|
success: true
|
||||||
}
|
}
|
||||||
@@ -36,6 +42,9 @@ function VideoRowListRowContentTask(input as object) as object
|
|||||||
feedSourcesIndex += 1
|
feedSourcesIndex += 1
|
||||||
if feedSourcesIndex >= feedSources.Count()
|
if feedSourcesIndex >= feedSources.Count()
|
||||||
feedContentNode.loadState = FeedLoadState.Loaded
|
feedContentNode.loadState = FeedLoadState.Loaded
|
||||||
|
if not someContentReadySet
|
||||||
|
rowList.someContentReady = false
|
||||||
|
end if
|
||||||
return {
|
return {
|
||||||
success: true
|
success: true
|
||||||
}
|
}
|
||||||
@@ -130,7 +139,8 @@ function VideoRowListRowContentTask(input as object) as object
|
|||||||
feedContentNode.loadState = FeedLoadState.LoadedPage
|
feedContentNode.loadState = FeedLoadState.LoadedPage
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if itemNodes.Count() > 0
|
if itemNodes.Count() > 0 and not someContentReadySet
|
||||||
|
someContentReadySet = true
|
||||||
rowList.someContentReady = true
|
rowList.someContentReady = true
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user