migrate from ts-rs to tauri-specta
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::services::auth::get_session_token;
|
||||
use tracing::info;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn quit_app() -> Result<(), String> {
|
||||
let app_handle = get_app_handle();
|
||||
app_handle.exit(0);
|
||||
@@ -11,6 +12,7 @@ pub fn quit_app() -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn restart_app() {
|
||||
let app_handle = get_app_handle();
|
||||
app_handle.restart();
|
||||
@@ -21,6 +23,7 @@ pub fn restart_app() {
|
||||
/// Validates server health, checks for a valid session token,
|
||||
/// then reconstructs the user session (re-fetches app data + WebSocket).
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn retry_connection() -> Result<(), String> {
|
||||
info!("Retrying connection...");
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ use crate::{
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn get_app_data() -> Result<UserData, String> {
|
||||
let guard = lock_r!(FDOLL);
|
||||
Ok(guard.user_data.clone())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn refresh_app_data() -> Result<UserData, String> {
|
||||
init_app_data_scoped(AppDataRefreshScope::All).await;
|
||||
let guard = lock_r!(FDOLL);
|
||||
@@ -19,6 +21,7 @@ pub async fn refresh_app_data() -> Result<UserData, String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn get_modules() -> Result<Vec<ModuleMetadata>, String> {
|
||||
let guard = lock_r!(FDOLL);
|
||||
Ok(guard.modules.metadatas.clone())
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
use crate::services::auth;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn logout_and_restart() -> Result<(), String> {
|
||||
auth::logout_and_restart().await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn login(email: String, password: String) -> Result<(), String> {
|
||||
auth::login_and_init_session(&email, &password)
|
||||
.await
|
||||
@@ -13,6 +15,7 @@ pub async fn login(email: String, password: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn register(
|
||||
email: String,
|
||||
password: String,
|
||||
@@ -30,6 +33,7 @@ pub async fn register(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn change_password(
|
||||
current_password: String,
|
||||
new_password: String,
|
||||
@@ -40,6 +44,7 @@ pub async fn change_password(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn reset_password(old_password: String, new_password: String) -> Result<(), String> {
|
||||
auth::reset_password(&old_password, &new_password)
|
||||
.await
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn get_client_config() -> AppConfig {
|
||||
let mut guard = lock_w!(FDOLL);
|
||||
guard.app_config = load_app_config();
|
||||
@@ -14,6 +15,7 @@ pub fn get_client_config() -> AppConfig {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn save_client_config(config: AppConfig) -> Result<(), String> {
|
||||
match save_app_config(config) {
|
||||
Ok(saved) => {
|
||||
@@ -26,6 +28,7 @@ pub fn save_client_config(config: AppConfig) -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn open_client_config_manager() -> Result<(), String> {
|
||||
open_config_manager_window().map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn get_dolls() -> Result<Vec<DollDto>, String> {
|
||||
DollsRemote::new()
|
||||
.get_dolls()
|
||||
@@ -17,6 +18,7 @@ pub async fn get_dolls() -> Result<Vec<DollDto>, String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn get_doll(id: String) -> Result<DollDto, String> {
|
||||
DollsRemote::new()
|
||||
.get_doll(&id)
|
||||
@@ -25,6 +27,7 @@ pub async fn get_doll(id: String) -> Result<DollDto, String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn create_doll(dto: CreateDollDto) -> Result<DollDto, String> {
|
||||
let result = DollsRemote::new()
|
||||
.create_doll(dto)
|
||||
@@ -37,6 +40,7 @@ pub async fn create_doll(dto: CreateDollDto) -> Result<DollDto, String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn update_doll(id: String, dto: UpdateDollDto) -> Result<DollDto, String> {
|
||||
let result = DollsRemote::new()
|
||||
.update_doll(&id, dto)
|
||||
@@ -55,6 +59,7 @@ pub async fn update_doll(id: String, dto: UpdateDollDto) -> Result<DollDto, Stri
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn delete_doll(id: String) -> Result<(), String> {
|
||||
DollsRemote::new()
|
||||
.delete_doll(&id)
|
||||
@@ -73,6 +78,7 @@ pub async fn delete_doll(id: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn set_active_doll(doll_id: String) -> Result<(), String> {
|
||||
UserRemote::new()
|
||||
.set_active_doll(&doll_id)
|
||||
@@ -85,6 +91,7 @@ pub async fn set_active_doll(doll_id: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn remove_active_doll() -> Result<(), String> {
|
||||
UserRemote::new()
|
||||
.remove_active_doll()
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::state::AppDataRefreshScope;
|
||||
use crate::commands::refresh_app_data;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn list_friends() -> Result<Vec<FriendshipResponseDto>, String> {
|
||||
FriendRemote::new()
|
||||
.get_friends()
|
||||
@@ -14,6 +15,7 @@ pub async fn list_friends() -> Result<Vec<FriendshipResponseDto>, String> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn search_users(username: Option<String>) -> Result<Vec<UserBasicDto>, String> {
|
||||
tracing::info!(
|
||||
"Tauri command search_users called with username: {:?}",
|
||||
@@ -30,6 +32,7 @@ pub async fn search_users(username: Option<String>) -> Result<Vec<UserBasicDto>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn send_friend_request(
|
||||
request: SendFriendRequestDto,
|
||||
) -> Result<FriendRequestResponseDto, String> {
|
||||
@@ -44,6 +47,7 @@ pub async fn send_friend_request(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn received_friend_requests() -> Result<Vec<FriendRequestResponseDto>, String> {
|
||||
FriendRemote::new()
|
||||
.get_received_requests()
|
||||
@@ -52,6 +56,7 @@ pub async fn received_friend_requests() -> Result<Vec<FriendRequestResponseDto>,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn sent_friend_requests() -> Result<Vec<FriendRequestResponseDto>, String> {
|
||||
FriendRemote::new()
|
||||
.get_sent_requests()
|
||||
@@ -60,6 +65,7 @@ pub async fn sent_friend_requests() -> Result<Vec<FriendRequestResponseDto>, Str
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn accept_friend_request(request_id: String) -> Result<FriendRequestResponseDto, String> {
|
||||
let result = FriendRemote::new()
|
||||
.accept_friend_request(&request_id)
|
||||
@@ -72,6 +78,7 @@ pub async fn accept_friend_request(request_id: String) -> Result<FriendRequestRe
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn deny_friend_request(request_id: String) -> Result<FriendRequestResponseDto, String> {
|
||||
let result = FriendRemote::new()
|
||||
.deny_friend_request(&request_id)
|
||||
@@ -84,6 +91,7 @@ pub async fn deny_friend_request(request_id: String) -> Result<FriendRequestResp
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn unfriend(friend_id: String) -> Result<(), String> {
|
||||
FriendRemote::new()
|
||||
.unfriend(&friend_id)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::{models::interaction::SendInteractionDto, services::interaction::send_interaction};
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn send_interaction_cmd(dto: SendInteractionDto) -> Result<(), String> {
|
||||
send_interaction(dto).await
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::models::dolls::DollDto;
|
||||
use crate::services::petpet;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn encode_pet_doll_gif_base64(doll: DollDto) -> Result<String, String> {
|
||||
petpet::encode_pet_doll_gif_base64(doll)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::services::sprite_recolor;
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn recolor_gif_base64(
|
||||
white_color_hex: String,
|
||||
black_color_hex: String,
|
||||
|
||||
Reference in New Issue
Block a user