Mountain/IPC/WindAirCommands/
CheckForUpdates.rs1
2use crate::{
7 IPC::WindAirCommands::{GetAirAddress, GetOrCreateAirClient, UpdateInfoDTO},
8 dev_log,
9};
10
11#[tauri::command]
12pub async fn CheckForUpdates(
13 current_version:Option<String>,
14
15 channel:Option<String>,
16) -> Result<UpdateInfoDTO::Struct, String> {
17 dev_log!(
18 "grpc",
19 "[WindAirCommands] CheckForUpdates called with version: {:?}, channel: {:?}",
20 current_version,
21 channel
22 );
23
24 let air_address = GetAirAddress::Fn()?;
25
26 let client = GetOrCreateAirClient::Fn(air_address).await?;
27
28 let request_id = uuid::Uuid::new_v4().to_string();
29
30 let current_version = current_version.unwrap_or_else(|| env!("CARGO_PKG_VERSION").to_string());
31
32 let channel = channel.unwrap_or_else(|| "stable".to_string());
33
34 let update_info = client
35 .check_for_updates(request_id, current_version, channel)
36 .await
37 .map_err(|e| format!("Update check failed: {:?}", e))?;
38
39 let result = UpdateInfoDTO::Struct {
40 update_available:update_info.update_available,
41
42 version:update_info.version,
43
44 download_url:update_info.download_url,
45
46 release_notes:update_info.release_notes,
47 };
48
49 dev_log!(
50 "grpc",
51 "[WindAirCommands] Update check completed: available={}",
52 result.update_available
53 );
54
55 Ok(result)
56}