Files
Modrinth-plus/packages/app-lib/src/api/settings.rs

39 lines
950 B
Rust
Raw Normal View History

//! Theseus profile management interface
pub use crate::{
state::{Hooks, MemorySettings, Profile, Settings, WindowSize},
State,
};
/// Gets entire settings
#[tracing::instrument]
pub async fn get() -> crate::Result<Settings> {
let state = State::get().await?;
let settings = Settings::get(&state.pool).await?;
Ok(settings)
}
/// Sets entire settings
#[tracing::instrument]
pub async fn set(settings: Settings) -> crate::Result<()> {
let state = State::get().await?;
settings.update(&state.pool).await?;
2023-07-21 20:16:07 -07:00
Ok(())
}
#[tracing::instrument]
pub async fn cancel_directory_change() -> crate::Result<()> {
let pool = crate::state::db::connect().await?;
let mut settings = Settings::get(&pool).await?;
if let Some(prev_custom_dir) = settings.prev_custom_dir {
settings.prev_custom_dir = None;
settings.custom_dir = Some(prev_custom_dir);
}
settings.update(&pool).await?;
Ok(())
}