game_manager_lib/commands/platforms/
steam.rs1use crate::commands::platforms::core::{
7 format_import_empty, format_import_summary, persist_source_games,
8};
9use crate::database::AppState;
10use crate::errors::AppError;
11use crate::sources::steam;
12use tauri::{AppHandle, Emitter, State};
13use tracing::info;
14
15#[tauri::command]
16pub async fn import_steam_library(
17 app: AppHandle,
18 state: State<'_, AppState>,
19 api_key: String,
20 steam_id: String,
21 steam_root: String,
22) -> Result<String, AppError> {
23 use crate::sources::providers::GameSource; let source = steam::SteamSource {
27 steam_root,
28 api_key,
29 steam_id,
30 };
31
32 let games = source.fetch_games().await?;
34
35 if games.is_empty() {
36 return Ok(format_import_empty("Steam"));
37 }
38
39 let (inserted, updated, _newly_imported) = persist_source_games(&state, games).await?;
41 let message = format_import_summary("Steam", inserted, updated);
42 info!("{}", message);
43
44 let _ = app.emit("library_updated", ());
46
47 Ok(message)
48}