fetch user profile 👍

This commit is contained in:
2025-12-05 22:26:28 +08:00
parent f522148489
commit 97d4bb279c
4 changed files with 25 additions and 18 deletions

View File

@@ -4,20 +4,29 @@ use tracing::{error, info};
use crate::{
get_app_handle,
services::overlay::{overlay_fullscreen, SCENE_WINDOW_LABEL},
services::{auth::get_tokens, preferences::create_preferences_window},
services::{
auth::get_tokens,
overlay::{overlay_fullscreen, SCENE_WINDOW_LABEL},
preferences::create_preferences_window,
},
state::init_app_data,
};
pub async fn start_fdoll() {
init_session().await;
bootstrap().await;
}
pub async fn init_session() {
async fn construct_app() {
init_app_data().await;
create_scene();
create_preferences_window();
}
pub async fn bootstrap() {
match get_tokens().await {
Some(_) => {
info!("User session restored");
create_scene();
create_preferences_window();
construct_app().await;
}
None => {
info!("No active session, user needs to authenticate");
@@ -25,8 +34,7 @@ pub async fn init_session() {
info!("Authentication successful, creating scene...");
tauri::async_runtime::spawn(async {
info!("Creating scene after auth success...");
create_scene();
create_preferences_window();
construct_app().await;
});
});
}

View File

@@ -1,3 +1,4 @@
use crate::state::init_app_data;
use crate::{lock_r, lock_w, state::FDOLL, APP_HANDLE};
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use flate2::{read::GzDecoder, write::GzEncoder, Compression};

View File

@@ -90,12 +90,6 @@ pub fn init_fdoll_state() {
async_runtime::spawn(async move {
crate::services::ws::init_ws_client().await;
});
// TODO: seems like even under `has_auth` token may not be present when init app data
async_runtime::spawn(async move {
info!("Initializing user data");
init_app_data().await;
});
}
info!("Initialized FDOLL state (WebSocket client & user data initializing asynchronously)");