diff --git a/README.md b/README.md index 9c7c732..d6edb19 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ # Friendolls (Desktop) -Run the following command in project root on first run & after changes to models on Rust side to generate TypeScript type bindings from Rust models +This repository contins source for Friendolls desktop app. Will add more info when the app scales. + +Run the following command in project root after changes to models on Rust side to generate TypeScript type bindings from Rust models ```sh -# unix -TS_RS_EXPORT_DIR="../src/types/bindings" cargo test export_bindings --manifest-path=./src-tauri/Cargo.toml +# average unix shells +TS_RS_EXPORT_DIR="../src/types/bindings" cargo test export_bindings --manifest-path="./src-tauri/Cargo.toml" ``` ```sh # powershell -$Env:TS_RS_EXPORT_DIR = "../src/types/bindings"; cargo test export_bindings --manifest-path=./src-tauri/Cargo.toml +$Env:TS_RS_EXPORT_DIR = "../src/types/bindings"; cargo test export_bindings --manifest-path="./src-tauri/Cargo.toml" ``` + +> _To the gods of programming, please grant me the perseverance to push through and get this app into production_ 🙏 diff --git a/src-tauri/src/app.rs b/src-tauri/src/app.rs index 171e933..9d97e7c 100644 --- a/src-tauri/src/app.rs +++ b/src-tauri/src/app.rs @@ -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; }); }); } diff --git a/src-tauri/src/services/auth.rs b/src-tauri/src/services/auth.rs index 40109b9..fcd140d 100644 --- a/src-tauri/src/services/auth.rs +++ b/src-tauri/src/services/auth.rs @@ -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}; diff --git a/src-tauri/src/state.rs b/src-tauri/src/state.rs index d97c2eb..8fa5c08 100644 --- a/src-tauri/src/state.rs +++ b/src-tauri/src/state.rs @@ -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)");