import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Navigation/Navigation.bs" import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" import "pkg:/source/AsyncTask/AsyncTask.bs" import "pkg:/source/AsyncTask/Tasks.bs" import "pkg:/source/utils/FocusManagement.bs" import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/Types.bs" function Init() m.titleLabel = m.top.findNode("titleLabel") m.closeButton = m.top.findNode("closeButton") m.testList = m.top.findNode("testList") m.closeButton.observeField("buttonSelected", FuncName(Close)) m.testList.observeField("itemSelected", FuncName(ShowTestDetails)) SetNavigation(m.closeButton, "up", m.testList) SetNavigation(m.testList, "down", m.closeButton) end function function OnFocusChange() as void if not m.top.focus return end if NodeSetFocus(m.closeButton, true) end function function OnkeyEvent(key as string, press as boolean) as boolean if NavigationKeyHandler(key, press).handled return true end if if key = "options" and press ' A pass-through to the app controller, so it can toggle picture-in-picture return false end if if key = "back" and press Close() return true end if return true end function function Close() if m.testingTask <> invalid m.testingTask.cancel = true end if m.appController@.PopScreen() end function function RunTestsTask() m.titleLabel.text = `Testing ${m.top.instance}` if m.testingTask <> invalid m.testingTask.cancel = true end if m.testingTask = AsyncTask.Start(Tasks.InvidiousInstanceTestingTask, { instance: m.top.instance listNode: m.testList }) end function function ShowTestDetails(event as object) as void selected = m.testList.itemSelected itemContent = m.testList.content.GetChild(selected) if StringUtils.IsNullOrEmpty(itemContent.details) return end if message = `Status: ${itemContent.state}\nTest duration: ${itemContent.duration}ms\nDetails: ${itemContent.details}` DialogUtils.ShowDialog(message, `Test: ${itemContent.title}`) end function