Add version check (#13)
This commit is contained in:
1 parent
a1484c01eb
commit
25b2ea7091
5 files changed
+68
-3
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/roku_modules/rokurequests/Requests.brs"
|
||||
|
||||
function Init()
|
||||
m.top.functionName = "TaskMain"
|
||||
end function
|
||||
|
||||
function TaskMain()
|
||||
latest = "N/A"
|
||||
response = Requests().request("HEAD", "https://github.com/iBicha/playlet/releases/latest", invalid)
|
||||
|
||||
if response.statusCode = 200
|
||||
if response.headers.location <> invalid
|
||||
regex = CreateObject("roRegex", "/v?(\d+\.\d+\.\d+)", "")
|
||||
match = regex.match(response.headers.location)
|
||||
if match.Count() = 2
|
||||
latest = match[1]
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
|
||||
m.top.setField("output", {
|
||||
latest: latest
|
||||
})
|
||||
end function
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<component name="AppVersionTask" extends="Task">
|
||||
<interface>
|
||||
<field id="input" type="assocarray" />
|
||||
<field id="output" type="assocarray" />
|
||||
</interface>
|
||||
</component>
|
||||
@@ -1,7 +1,13 @@
|
||||
import "pkg:/source/utils/General.bs"
|
||||
import "pkg:/source/roku_modules/rokupromise/Promise.brs"
|
||||
|
||||
function Init()
|
||||
m.versionLabel = m.top.findNode("VersionLabel")
|
||||
m.top.url = `http:/${GetLocalIpAddress()}:8888`
|
||||
appInfo = GetAppInfo()
|
||||
m.currentVersion = appInfo.version
|
||||
SetVersionLabel(m.currentVersion, "N/A")
|
||||
GetLatestVersion()
|
||||
end function
|
||||
|
||||
function OnUrlSet()
|
||||
@@ -13,3 +19,17 @@ function OnUrlSet()
|
||||
urlLabel = m.top.findNode("urlLabel")
|
||||
urlLabel.text = url
|
||||
end function
|
||||
|
||||
function GetLatestVersion()
|
||||
createTaskPromise("AppVersionTask", {
|
||||
input: {}
|
||||
}).then(function(task as object) as void
|
||||
if task.output.latest <> invalid
|
||||
SetVersionLabel(m.currentVersion, task.output.latest)
|
||||
end if
|
||||
end function)
|
||||
end function
|
||||
|
||||
function SetVersionLabel(current as string, latest as string)
|
||||
m.versionLabel.text = `Version: ${current} | Latest: ${latest}`
|
||||
end function
|
||||
@@ -5,12 +5,20 @@
|
||||
<field id="url" type="string" onChange="OnUrlSet" />
|
||||
</interface>
|
||||
<children>
|
||||
<Label
|
||||
id='VersionLabel'
|
||||
height='50'
|
||||
width='1280'
|
||||
font='font:MediumBoldSystemFont'
|
||||
horizAlign="center"
|
||||
translation="[0,100]"
|
||||
/>
|
||||
<QRPoster
|
||||
id='SettingsQRPoster'
|
||||
loadWidth='500'
|
||||
loadHeight='500'
|
||||
loadWidth='400'
|
||||
loadHeight='400'
|
||||
loadPadding='20'
|
||||
translation='[395, 60]' />
|
||||
translation='[440, 160]' />
|
||||
|
||||
<Label
|
||||
id='UrlLabel'
|
||||
|
||||
Reference in new issue
Block a user