user's own doll color scheme in neko

This commit is contained in:
2026-03-09 19:04:53 +08:00
parent d582ea7fe8
commit 02f1119254
4 changed files with 36 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
use crate::{
lock_r,
models::app_data::UserData,
models::{app_data::UserData, dolls::DollColorSchemeDto},
services::presence_modules::models::ModuleMetadata,
state::{init_app_data_scoped, AppDataRefreshScope, FDOLL},
};
@@ -26,3 +26,27 @@ pub fn get_modules() -> Result<Vec<ModuleMetadata>, String> {
let guard = lock_r!(FDOLL);
Ok(guard.modules.metadatas.clone())
}
#[tauri::command]
#[specta::specta]
pub fn get_active_doll_color_scheme() -> Result<Option<DollColorSchemeDto>, String> {
let guard = lock_r!(FDOLL);
let active_doll_id = guard
.user_data
.user
.as_ref()
.and_then(|u| u.active_doll_id.as_deref());
match active_doll_id {
Some(active_doll_id) => {
let color_scheme = guard
.user_data
.dolls
.as_ref()
.and_then(|dolls| dolls.iter().find(|d| d.id == active_doll_id))
.map(|d| d.configuration.color_scheme.clone());
Ok(color_scheme)
}
None => Ok(None),
}
}

View File

@@ -6,7 +6,7 @@ use crate::{
},
};
use commands::app::{quit_app, restart_app, retry_connection};
use commands::app_state::{get_app_data, refresh_app_data};
use commands::app_state::{get_app_data, get_active_doll_color_scheme, refresh_app_data};
use commands::auth::{change_password, login, logout_and_restart, register, reset_password};
use commands::config::{get_client_config, open_client_config_manager, save_client_config};
use commands::dolls::{
@@ -65,6 +65,7 @@ pub fn run() {
.error_handling(ErrorHandlingMode::Throw)
.commands(collect_commands![
get_app_data,
get_active_doll_color_scheme,
refresh_app_data,
list_friends,
search_users,