-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<define-template id="update-available"> | ||
<dialog title="Update Available" buttons="@buttons"> | ||
<div style="flex-direction: column; align-items: center; justify-content: center; margin: 4vmin;"> | ||
<div style="flex-direction: column;"> | ||
<med-text text="@body" /> | ||
</div> | ||
<hr /> | ||
<div> | ||
<med-link label="Download" color="#8888ff" href="@download" /> | ||
</div> | ||
</div> | ||
</dialog> | ||
</define-template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use isahc::ReadResponseExt; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct GitData { | ||
tag_name: String, | ||
html_url: String, | ||
body: String, | ||
} | ||
|
||
pub fn build_date() -> chrono::NaiveDate { | ||
chrono::NaiveDate::parse_from_str(build_time::build_time_utc!("%Y-%m-%d"), "%Y-%m-%d").unwrap() | ||
} | ||
|
||
pub fn check_update() -> Option<(String, String)> { | ||
let latest: GitData = | ||
isahc::get("https://api.github.com/repos/decentraland/bevy-explorer/releases/latest") | ||
.ok()? | ||
.json() | ||
.ok()?; | ||
let latest_date = latest | ||
.tag_name | ||
.split('-') | ||
.skip(1) | ||
.take(3) | ||
.collect::<Vec<_>>() | ||
.join("-"); | ||
let latest_date = chrono::NaiveDate::parse_from_str(&latest_date, "%Y-%m-%d").ok()?; | ||
|
||
if latest_date > build_date() { | ||
Some((latest.body, latest.html_url)) | ||
} else { | ||
None | ||
} | ||
} |