2023-04-03 13:46:04 -07:00
|
|
|
use crate::api::Result;
|
|
|
|
|
use theseus::prelude::*;
|
|
|
|
|
|
2023-06-28 09:58:58 -07:00
|
|
|
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
|
|
|
|
tauri::plugin::Builder::new("settings")
|
2024-08-16 23:20:11 -07:00
|
|
|
.invoke_handler(tauri::generate_handler![
|
|
|
|
|
settings_get,
|
|
|
|
|
settings_set,
|
|
|
|
|
cancel_directory_change
|
|
|
|
|
])
|
2023-06-28 09:58:58 -07:00
|
|
|
.build()
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 13:46:04 -07:00
|
|
|
// Get full settings
|
2023-06-28 09:58:58 -07:00
|
|
|
// invoke('plugin:settings|settings_get')
|
2023-04-03 13:46:04 -07:00
|
|
|
#[tauri::command]
|
2023-05-19 18:59:32 -07:00
|
|
|
pub async fn settings_get() -> Result<Settings> {
|
|
|
|
|
let res = settings::get().await?;
|
|
|
|
|
Ok(res)
|
2023-04-03 13:46:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set full settings
|
2023-06-28 09:58:58 -07:00
|
|
|
// invoke('plugin:settings|settings_set', settings)
|
2023-04-03 13:46:04 -07:00
|
|
|
#[tauri::command]
|
2023-05-19 18:59:32 -07:00
|
|
|
pub async fn settings_set(settings: Settings) -> Result<()> {
|
|
|
|
|
settings::set(settings).await?;
|
2023-04-03 13:46:04 -07:00
|
|
|
Ok(())
|
|
|
|
|
}
|
2024-08-16 23:20:11 -07:00
|
|
|
|
|
|
|
|
#[tauri::command]
|
|
|
|
|
pub async fn cancel_directory_change() -> Result<()> {
|
2026-02-02 08:10:23 -05:00
|
|
|
let state = State::get().await?;
|
|
|
|
|
let identifier = &state.app_identifier;
|
|
|
|
|
|
|
|
|
|
settings::cancel_directory_change(identifier).await?;
|
2024-08-16 23:20:11 -07:00
|
|
|
Ok(())
|
|
|
|
|
}
|