chore: linting

This commit is contained in:
zhom
2025-06-17 07:00:18 +04:00
parent 130f8b86d1
commit 703154b30f
3 changed files with 41 additions and 43 deletions
+36 -41
View File
@@ -121,51 +121,48 @@ impl AutoUpdater {
Ok(notifications) Ok(notifications)
} }
pub async fn check_for_updates_with_progress( pub async fn check_for_updates_with_progress(&self, app_handle: &tauri::AppHandle) {
&self, // Check for browser updates and trigger auto-downloads
app_handle: &tauri::AppHandle, match self.check_for_updates().await {
) { Ok(update_notifications) => {
// Check for browser updates and trigger auto-downloads if !update_notifications.is_empty() {
match self.check_for_updates().await { println!(
Ok(update_notifications) => { "Found {} browser updates to auto-download",
if !update_notifications.is_empty() { update_notifications.len()
);
// Trigger automatic downloads for each update
for notification in update_notifications {
println!( println!(
"Found {} browser updates to auto-download", "Auto-downloading {} version {}",
update_notifications.len() notification.browser, notification.new_version
); );
// Trigger automatic downloads for each update // Emit a custom event to trigger auto-download
for notification in update_notifications { let auto_update_event = serde_json::json!({
println!( "browser": notification.browser,
"Auto-downloading {} version {}", "new_version": notification.new_version,
notification.browser, notification.new_version "notification_id": notification.id,
"affected_profiles": notification.affected_profiles
});
if let Err(e) = app_handle.emit("browser-auto-update-available", &auto_update_event) {
eprintln!(
"Failed to emit auto-update event for {}: {e}",
notification.browser
); );
} else {
// Emit a custom event to trigger auto-download println!("Emitted auto-update event for {}", notification.browser);
let auto_update_event = serde_json::json!({
"browser": notification.browser,
"new_version": notification.new_version,
"notification_id": notification.id,
"affected_profiles": notification.affected_profiles
});
if let Err(e) = app_handle.emit("browser-auto-update-available", &auto_update_event) {
eprintln!(
"Failed to emit auto-update event for {}: {e}",
notification.browser
);
} else {
println!("Emitted auto-update event for {}", notification.browser);
}
} }
} else {
println!("No browser updates needed");
} }
} else {
println!("No browser updates needed");
} }
Err(e) => { }
eprintln!("Failed to check for browser updates: {e}"); Err(e) => {
} eprintln!("Failed to check for browser updates: {e}");
}
} }
} }
@@ -475,9 +472,7 @@ pub async fn complete_browser_update_with_auto_update(
} }
#[tauri::command] #[tauri::command]
pub async fn check_for_updates_with_progress( pub async fn check_for_updates_with_progress(app_handle: tauri::AppHandle) {
app_handle: tauri::AppHandle,
) {
let updater = AutoUpdater::new(); let updater = AutoUpdater::new();
updater.check_for_updates_with_progress(&app_handle).await; updater.check_for_updates_with_progress(&app_handle).await;
} }
+1 -1
View File
@@ -298,7 +298,7 @@ pub fn run() {
}); });
let app_handle_auto_updater = app.handle().clone(); let app_handle_auto_updater = app.handle().clone();
// Start the auto-update check task separately // Start the auto-update check task separately
tauri::async_runtime::spawn(async move { tauri::async_runtime::spawn(async move {
auto_updater::check_for_updates_with_progress(app_handle_auto_updater).await; auto_updater::check_for_updates_with_progress(app_handle_auto_updater).await;
+4 -1
View File
@@ -385,7 +385,10 @@ impl VersionUpdater {
tokio::time::sleep(Duration::from_millis(200)).await; tokio::time::sleep(Duration::from_millis(200)).await;
} }
self.auto_updater.check_for_updates_with_progress(app_handle).await; self
.auto_updater
.check_for_updates_with_progress(app_handle)
.await;
// Emit completion event // Emit completion event
let progress = VersionUpdateProgress { let progress = VersionUpdateProgress {