* 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
35 lines
908 B
Plaintext
35 lines
908 B
Plaintext
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
|