Make state optional in the frontend state to allow passing an uninitialized state

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent e71ee47e50
commit 31eadd2e43

@ -1,6 +1,6 @@
[package] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.15.0" version = "0.16.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"

@ -185,7 +185,7 @@ pub async fn select_repository(
} }
#[tauri::command] #[tauri::command]
pub async fn get_frontend_state(api_state: ApiAccess<'_>) -> PluginResult<String> { pub async fn get_frontend_state(api_state: ApiAccess<'_>) -> PluginResult<Option<String>> {
let api = api_state.api().await?; let api = api_state.api().await?;
let state = api.repo.get_frontend_state().await?; let state = api.repo.get_frontend_state().await?;
@ -195,7 +195,9 @@ pub async fn get_frontend_state(api_state: ApiAccess<'_>) -> PluginResult<String
#[tauri::command] #[tauri::command]
pub async fn set_frontend_state(api_state: ApiAccess<'_>, state: String) -> PluginResult<()> { pub async fn set_frontend_state(api_state: ApiAccess<'_>, state: String) -> PluginResult<()> {
let api = api_state.api().await?; let api = api_state.api().await?;
api.repo.set_frontend_state(FrontendState { state }).await?; api.repo
.set_frontend_state(FrontendState { state: Some(state) })
.await?;
Ok(()) Ok(())
} }

@ -2,5 +2,5 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
pub struct FrontendState { pub struct FrontendState {
pub state: String, pub state: Option<String>,
} }

Loading…
Cancel
Save