consolidation & handling of data from backend pt 2

This commit is contained in:
2026-03-08 23:04:49 +08:00
parent 2aa1d5f92f
commit 2dcc202540
13 changed files with 217 additions and 102 deletions

View File

@@ -1,5 +1,6 @@
// in app-core/src/state.rs
use crate::{
lock_r,
lock_w,
models::{app_data::UserData, dolls::DollDto},
services::{
@@ -7,7 +8,7 @@ use crate::{
presence_modules::models::ModuleMetadata,
},
};
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::sync::{Arc, LazyLock, RwLock};
use tauri::tray::TrayIcon;
use tracing::info;
@@ -55,6 +56,22 @@ pub struct AppState {
pub static FDOLL: LazyLock<Arc<RwLock<AppState>>> =
LazyLock::new(|| Arc::new(RwLock::new(AppState::default())));
pub fn get_known_friend_ids() -> HashSet<String> {
let guard = lock_r!(FDOLL);
guard
.user_data
.friends
.as_ref()
.map(|friends| {
friends
.iter()
.filter_map(|friendship| friendship.friend.as_ref().map(|friend| friend.id.clone()))
.collect()
})
.unwrap_or_default()
}
/// Populate app state with initial
/// values and necesary client instances.
pub fn init_app_state() {