From 88eb489352e5be34d91ec95c6c4db0753ebda14b Mon Sep 17 00:00:00 2001 From: Timon Date: Fri, 13 Feb 2026 19:55:30 +0000 Subject: [PATCH] WIP --- desktop/update/src/lib.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/desktop/update/src/lib.rs b/desktop/update/src/lib.rs index b05bcc63d9..136bb102c8 100644 --- a/desktop/update/src/lib.rs +++ b/desktop/update/src/lib.rs @@ -1,21 +1,20 @@ 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 response = client.post(UPDATE_CHECK_URL).json(&info).send().await; match response { - Ok(response) => { - if response.status().is_success() { - match response.json::().await { - Ok(result) => result, - Err(_) => Status::Unknown, - } - } else { - Status::Unknown + Ok(response) if response.status().is_success() => { + if let Ok(result) = response.json::().await { + return result; } } - Err(_) => Status::Unknown, + _ => {} + } + UpdateCheckRsponse { + status: Status::Unknown, + messages: Vec::new(), } } @@ -69,17 +68,20 @@ pub enum Source { Other(String), } -struct UpdateCheckRsponse { +#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct UpdateCheckRsponse { status: Status, messages: Vec, } -struct Message { +#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Message { title: String, body: String, action: Action, } +#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub enum Action { OpenUrl(String), PerformAutoUpdate,