mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-04 06:34:17 +02:00
Notify of plugin updates and add update UX (#339)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::api::{
|
||||
PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates, search_plugins,
|
||||
PluginNameVersion, PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates,
|
||||
search_plugins,
|
||||
};
|
||||
use crate::error::Result;
|
||||
use crate::install::{delete_and_uninstall, download_and_install};
|
||||
use tauri::{AppHandle, Runtime, WebviewWindow, command};
|
||||
use tauri::{AppHandle, Manager, Runtime, WebviewWindow, command};
|
||||
use yaak_models::models::Plugin;
|
||||
|
||||
#[command]
|
||||
@@ -36,3 +37,34 @@ pub(crate) async fn uninstall<R: Runtime>(
|
||||
pub(crate) async fn updates<R: Runtime>(app_handle: AppHandle<R>) -> Result<PluginUpdatesResponse> {
|
||||
check_plugin_updates(&app_handle).await
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub(crate) async fn update_all<R: Runtime>(
|
||||
window: WebviewWindow<R>,
|
||||
) -> Result<Vec<PluginNameVersion>> {
|
||||
use log::info;
|
||||
|
||||
// Get list of available updates (already filtered to only registry plugins)
|
||||
let updates = check_plugin_updates(&window.app_handle()).await?;
|
||||
|
||||
if updates.plugins.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
let mut updated = Vec::new();
|
||||
|
||||
for update in updates.plugins {
|
||||
info!("Updating plugin: {} to version {}", update.name, update.version);
|
||||
match download_and_install(&window, &update.name, Some(update.version.clone())).await {
|
||||
Ok(_) => {
|
||||
info!("Successfully updated plugin: {}", update.name);
|
||||
updated.push(update.clone());
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to update plugin {}: {:?}", update.name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(updated)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user