Search screen (#10)
* Search screen with keyboard and suggestions * Clear search on visibility change * Search page works * Local search history * Use built-in delete function * Changelog * Animation * Adjust suggestions * Web play video always goes to home
This commit is contained in:
1 parent
22dfe785f1
commit
740440c3a7
15 files changed
+395
-22
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import "pkg:/source/services/Invidious.bs"
|
||||
import "pkg:/components/SearchScreen/SearchHistory.bs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "TaskMain"
|
||||
end function
|
||||
|
||||
function TaskMain()
|
||||
input = m.top.getField("input")
|
||||
q = input.q
|
||||
|
||||
searchSuggestsions = q <> "" ? Invidious.SearchSuggestions(q) : invalid
|
||||
|
||||
history = GetSavedSearchHistory(q)
|
||||
|
||||
if searchSuggestsions <> invalid
|
||||
history = MergeSearchSuggestions(history, searchSuggestsions.suggestions)
|
||||
end if
|
||||
|
||||
m.top.setField("output", {
|
||||
q: q,
|
||||
response: history
|
||||
})
|
||||
end function
|
||||
|
||||
function MergeSearchSuggestions(history as object, queryResults as object, maxItems = 10 as integer) as object
|
||||
if queryResults = invalid
|
||||
return history
|
||||
end if
|
||||
while history.Count() < maxItems and queryResults.Count() > 0
|
||||
history.push(queryResults.shift())
|
||||
end while
|
||||
return history
|
||||
end function
|
||||
Reference in new issue
Block a user