mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 07:48:12 +08:00
WIP
This commit is contained in:
+14
-12
@@ -1,21 +1,20 @@
|
|||||||
const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update";
|
const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update";
|
||||||
|
|
||||||
async fn check_for_update(info: Info) -> Status {
|
async fn check_for_update(info: Info) -> UpdateCheckRsponse {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let response = client.post(UPDATE_CHECK_URL).json(&info).send().await;
|
let response = client.post(UPDATE_CHECK_URL).json(&info).send().await;
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
Ok(response) => {
|
Ok(response) if response.status().is_success() => {
|
||||||
if response.status().is_success() {
|
if let Ok(result) = response.json::<UpdateCheckRsponse>().await {
|
||||||
match response.json::<Status>().await {
|
return result;
|
||||||
Ok(result) => result,
|
|
||||||
Err(_) => Status::Unknown,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Status::Unknown
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => Status::Unknown,
|
_ => {}
|
||||||
|
}
|
||||||
|
UpdateCheckRsponse {
|
||||||
|
status: Status::Unknown,
|
||||||
|
messages: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,17 +68,20 @@ pub enum Source {
|
|||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateCheckRsponse {
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct UpdateCheckRsponse {
|
||||||
status: Status,
|
status: Status,
|
||||||
messages: Vec<Message>,
|
messages: Vec<Message>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Message {
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
|
pub struct Message {
|
||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
action: Action,
|
action: Action,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
OpenUrl(String),
|
OpenUrl(String),
|
||||||
PerformAutoUpdate,
|
PerformAutoUpdate,
|
||||||
|
|||||||
Reference in New Issue
Block a user