diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs index 16b651839..cbe3d0b13 100644 --- a/src-tauri/src/github/release_notes.rs +++ b/src-tauri/src/github/release_notes.rs @@ -98,19 +98,33 @@ pub async fn check_is_flightcore_outdated() -> Result { #[tauri::command] pub async fn get_northstar_release_notes() -> Result, String> { - let url = "https://api.github.com/repos/R2Northstar/Northstar/releases"; - let res = match fetch_github_releases_api(url).await { - Ok(res) => res, - Err(err) => return Err(format!("Failed getting Northstar release notes: {err}")), - }; + let octocrab = octocrab::instance(); + let page = octocrab + .repos("R2Northstar", "Northstar") + .releases() + .list() + // Optional Parameters + .per_page(25) + .page(1u32) + // Send the request + .send() + .await + .unwrap(); + + // TODO there's probably a way to automatically serialize into the struct but I don't know yet how to + let mut release_info_vector: Vec = vec![]; + for item in page.items { + let release_info = ReleaseInfo { + name: item.name.ok_or(String::from("Release name not found"))?, + published_at: item + .published_at + .ok_or(String::from("Release date not found"))? + .to_rfc3339(), + body: item.body.ok_or(String::from("Release body not found"))?, + }; + release_info_vector.push(release_info); + } - let release_info_vector: Vec = match serde_json::from_str(&res) { - Ok(res) => res, - Err(err) => { - log::warn!("{err}"); - return Err("Could not fetch release notes. JSON was not well-formatted".to_string()); - } - }; log::info!("Done checking GitHub API"); Ok(release_info_vector)