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