diff --git a/CHANGELOG.md b/CHANGELOG.md
index 199f5427..d147cc05 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
- 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
diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs
index 5e336a2c..c2df19b8 100644
--- a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs
+++ b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs
@@ -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()
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowList.bs b/playlet-lib/src/components/VideoFeed/VideoRowList.bs
index eda2b438..6e62f248 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowList.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowList.bs
@@ -218,7 +218,6 @@ end function
function InitContent() as void
CancelCurrentTasks()
- m.top.someContentReady = false
if m.top.feeds = invalid
m.top.content = invalid
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowList.xml b/playlet-lib/src/components/VideoFeed/VideoRowList.xml
index e35e338c..c68d3b67 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowList.xml
+++ b/playlet-lib/src/components/VideoFeed/VideoRowList.xml
@@ -6,7 +6,13 @@
-
+
+
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
index f18badb6..feb23164 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
@@ -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