1 parent
dccbfd7d86
commit
17f81c60c8
20 files changed
+636
-447
No files matched your search
+10
-11
@@ -7,8 +7,7 @@
|
||||
/// versionCode. The latest-release API names the download URLs of both assets.
|
||||
|
||||
///|
|
||||
pub let release_api : String =
|
||||
"https://git.site.latha.org/api/v1/repos/experiments/launcher/releases/latest"
|
||||
pub let release_api : String = "https://git.site.latha.org/api/v1/repos/experiments/launcher/releases/latest"
|
||||
|
||||
///|
|
||||
pub let apk_asset : String = "ultra-launcher.apk"
|
||||
@@ -45,12 +44,12 @@ pub fn parse_release(text : String) -> Release? {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some({ tag: @jsonx.str(json, "tag_name"), version_url, apk_url })
|
||||
Some({ tag: @jsonx.str(json, "tag_name"), version_url, apk_url, })
|
||||
}
|
||||
|
||||
///|
|
||||
/// The versionCode in a `version.json`.
|
||||
pub fn parse_version(text : String) -> Int? {
|
||||
pub fn parse_version(text : String) -> Int32? {
|
||||
guard @jsonx.parse(text) is Some(json) else { return None }
|
||||
match @jsonx.get(json, "versionCode") {
|
||||
Some(Number(n, ..)) => Some(n.to_int())
|
||||
@@ -60,7 +59,7 @@ pub fn parse_version(text : String) -> Int? {
|
||||
|
||||
///|
|
||||
/// The versionCode a release tag `build-<N>` stands for.
|
||||
pub fn tag_version(tag : String) -> Int? {
|
||||
pub fn tag_version(tag : String) -> Int32? {
|
||||
guard tag.has_prefix("build-") else { return None }
|
||||
let rest = tag.clamped_view(start=6)
|
||||
if rest.length() == 0 {
|
||||
@@ -79,20 +78,20 @@ pub fn tag_version(tag : String) -> Int? {
|
||||
///|
|
||||
#derive(Eq, Debug)
|
||||
pub(all) enum Decision {
|
||||
UpToDate(Int)
|
||||
UpToDate(Int32)
|
||||
/// A newer build exists and should be installed.
|
||||
Install(Int)
|
||||
Install(Int32)
|
||||
/// The user already cancelled this build's install; not offered again unless they ask.
|
||||
Declined(Int)
|
||||
Declined(Int32)
|
||||
}
|
||||
|
||||
///|
|
||||
/// `latest` is the newest published versionCode, `installed` the running one, `declined`
|
||||
/// the last build whose install the user cancelled (-1: none).
|
||||
pub fn decide(
|
||||
latest : Int,
|
||||
installed : Int,
|
||||
declined : Int,
|
||||
latest : Int32,
|
||||
installed : Int32,
|
||||
declined : Int32,
|
||||
manual~ : Bool,
|
||||
) -> Decision {
|
||||
if latest <= installed {
|
||||
|
||||
Reference in new issue
Block a user