game_manager_lib/commands/platforms/
xbox.rs1use crate::commands::platforms::core::{
4 format_import_empty, format_import_summary, persist_source_games,
5};
6use crate::database::AppState;
7use crate::errors::AppError;
8use tauri::{AppHandle, Emitter, State};
9use tracing::info;
10
11#[tauri::command]
12pub async fn import_xbox_games(
13 app: AppHandle,
14 state: State<'_, AppState>,
15) -> Result<String, AppError> {
16 let games = crate::sources::xbox::import_installed()?;
17
18 if games.is_empty() {
19 return Ok(format_import_empty("Xbox"));
20 }
21
22 let (inserted, updated, _newly_imported) = persist_source_games(&state, games).await?;
23 let message = format_import_summary("Xbox", inserted, updated);
24 info!("{}", message);
25
26 let _ = app.emit("library_updated", ());
27
28 Ok(message)
29}