doll active state
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::{
|
||||
FriendRemote, FriendRequestResponseDto, FriendshipResponseDto, SendFriendRequestDto,
|
||||
UserBasicDto,
|
||||
},
|
||||
remotes::user::UserRemote,
|
||||
services::cursor::start_cursor_tracking,
|
||||
state::{init_app_data, FDOLL},
|
||||
};
|
||||
@@ -192,6 +193,22 @@ async fn delete_doll(id: String) -> Result<(), String> {
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn set_active_doll(doll_id: String) -> Result<(), String> {
|
||||
UserRemote::new()
|
||||
.set_active_doll(&doll_id)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn remove_active_doll() -> Result<(), String> {
|
||||
UserRemote::new()
|
||||
.remove_active_doll()
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn recolor_gif_base64(
|
||||
white_color_hex: String,
|
||||
@@ -235,6 +252,8 @@ pub fn run() {
|
||||
create_doll,
|
||||
update_doll,
|
||||
delete_doll,
|
||||
set_active_doll,
|
||||
remove_active_doll,
|
||||
recolor_gif_base64,
|
||||
quit_app
|
||||
])
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct UserBasicDto {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub username: Option<String>,
|
||||
pub active_doll_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||
|
||||
@@ -18,6 +18,7 @@ pub struct UserProfile {
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
pub last_login_at: Option<String>,
|
||||
pub active_doll_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Clone, Debug, TS)]
|
||||
@@ -79,4 +80,18 @@ impl UserRemote {
|
||||
resp.error_for_status()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_active_doll(&self, doll_id: &str) -> Result<(), Error> {
|
||||
let url = format!("{}/users/me/active-doll/{}", self.base_url, doll_id);
|
||||
let resp = with_auth(self.client.put(url)).await.send().await?;
|
||||
resp.error_for_status()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn remove_active_doll(&self) -> Result<(), Error> {
|
||||
let url = format!("{}/users/me/active-doll", self.base_url);
|
||||
let resp = with_auth(self.client.delete(url)).await.send().await?;
|
||||
resp.error_for_status()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user