user's own doll color scheme in neko
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -8,6 +8,9 @@ export const commands = {
|
||||
async getAppData() : Promise<UserData> {
|
||||
return await TAURI_INVOKE("get_app_data");
|
||||
},
|
||||
async getActiveDollColorScheme() : Promise<DollColorSchemeDto | null> {
|
||||
return await TAURI_INVOKE("get_active_doll_color_scheme");
|
||||
},
|
||||
async refreshAppData() : Promise<UserData> {
|
||||
return await TAURI_INVOKE("refresh_app_data");
|
||||
},
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
let spriteUrl = $state("");
|
||||
|
||||
$effect(() => {
|
||||
getSpriteSheetUrl().then((url) => {
|
||||
spriteUrl = url;
|
||||
$appData;
|
||||
if (!$appData) return;
|
||||
commands.getActiveDollColorScheme().then((colorScheme) => {
|
||||
getSpriteSheetUrl(colorScheme ?? undefined).then((url) => {
|
||||
spriteUrl = url;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user