Generated task (#34)
* Async stash * tweak * Kinda works * Things work fine * Home grid task test * Convert some promises to regular tasks (#33) * Remove promise * Sponsorblock view task * Complete task cleanups * Prevent parallel search tasks * Comment * Changelog * Rename task, handle cleanups * Support task by name * Small changes
This commit is contained in:
1 parent
9a65bd4657
commit
fc20cfd7b4
27 files changed
+633
-236
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import "pkg:/source/roku_modules/rokupromise/Promise.brs"
|
||||
import "pkg:/source/asyncTask/asyncTask.bs"
|
||||
import "pkg:/components/VideoPlayer/Video.bs"
|
||||
import "pkg:/components/HomeGridScreen/HomeGridScreenTask.bs"
|
||||
|
||||
function Init()
|
||||
m.rowList = m.top.FindNode("rowList")
|
||||
@@ -23,6 +24,7 @@ function OnRefresh()
|
||||
end function
|
||||
|
||||
function InitContent()
|
||||
' TODO: stop any currently running tasks before starting a new batch of tasks
|
||||
m.sortedContent = []
|
||||
contentNode = CreateObject("roSGNode", "ContentNode")
|
||||
contentNode.Update({
|
||||
@@ -54,18 +56,16 @@ function StartFetchTask() as void
|
||||
return
|
||||
end if
|
||||
|
||||
createTaskPromise("HomeGridScreenTask", {
|
||||
input: {
|
||||
index: currentLoadingIndex,
|
||||
requestData: m.defaultLayout[currentLoadingIndex]
|
||||
}
|
||||
}).then(function(task as object)
|
||||
StartAsyncTask(GetHomeScreenContent, {
|
||||
index: currentLoadingIndex,
|
||||
requestData: m.defaultLayout[currentLoadingIndex]
|
||||
}, function(output as object)
|
||||
' TODO: this whole logic is not good.
|
||||
' The view should have placeholder, and child nodes get replaced as
|
||||
' They get ready.
|
||||
m.sortedContent.Push(task.output)
|
||||
m.sortedContent.Push(output.result)
|
||||
|
||||
if task.output.rootChildren.Count() > 0
|
||||
if output.result.rootChildren.Count() > 0
|
||||
m.sortedContent.SortBy("index")
|
||||
|
||||
newChildren = []
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
import "pkg:/source/services/InvidiousService.bs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "TaskMain"
|
||||
end function
|
||||
|
||||
function TaskMain()
|
||||
@asynctask
|
||||
function GetHomeScreenContent(input as object) as object
|
||||
rootChildren = []
|
||||
|
||||
invidious = new InvidiousService()
|
||||
service = new InvidiousService()
|
||||
|
||||
input = m.top.getField("input")
|
||||
requestData = input.requestData
|
||||
|
||||
response = invidious.MakeRequest(requestData)
|
||||
response = service.MakeRequest(requestData)
|
||||
if response <> invalid
|
||||
if type(response) = "roAssociativeArray"
|
||||
for each key in response
|
||||
@@ -29,10 +25,10 @@ function TaskMain()
|
||||
end if
|
||||
end if
|
||||
|
||||
m.top.setField("output", {
|
||||
return {
|
||||
index: input.index,
|
||||
rootChildren: rootChildren
|
||||
})
|
||||
}
|
||||
end function
|
||||
|
||||
function GetCategoryContent(category as string, json as object) as object
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="HomeGridScreenTask" extends="Task">
|
||||
<interface>
|
||||
<field id="input" type="assocarray" />
|
||||
<field id="output" type="assocarray" />
|
||||
</interface>
|
||||
</component>
|
||||
Reference in new issue
Block a user