-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#361: Notify user when app update is available
- Loading branch information
1 parent
a4c35da
commit ba0dbf7
Showing
16 changed files
with
175 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ mod cli; | |
mod cloud; | ||
mod gui; | ||
mod lang; | ||
mod metadata; | ||
mod path; | ||
mod prelude; | ||
mod resource; | ||
|
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,36 @@ | ||
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] | ||
pub struct Release { | ||
pub version: semver::Version, | ||
pub url: String, | ||
} | ||
|
||
impl Release { | ||
const URL: &'static str = "https://api.github.com/repos/mtkennerly/ludusavi/releases/latest"; | ||
|
||
pub async fn fetch() -> Result<Self, crate::prelude::AnyError> { | ||
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)] | ||
pub struct Response { | ||
pub html_url: String, | ||
pub tag_name: String, | ||
} | ||
|
||
let req = reqwest::Client::new() | ||
.get(Self::URL) | ||
.header(reqwest::header::USER_AGENT, &*crate::prelude::USER_AGENT); | ||
let res = req.send().await?; | ||
|
||
match res.status() { | ||
reqwest::StatusCode::OK => { | ||
let bytes = res.bytes().await?.to_vec(); | ||
let raw = String::from_utf8(bytes)?; | ||
let parsed = serde_json::from_str::<Response>(&raw)?; | ||
|
||
Ok(Self { | ||
version: semver::Version::parse(parsed.tag_name.trim_start_matches('v'))?, | ||
url: parsed.html_url, | ||
}) | ||
} | ||
code => Err(format!("status code: {code:?}").into()), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.