move crate root feature module files into folders
This commit is contained in:
@@ -51,7 +51,7 @@ pub fn reconcile_cursor(handle: &AppHandle) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(error) = crate::cursor::init(handle) {
|
if let Err(error) = crate::cursor::start_tracking(handle) {
|
||||||
eprintln!("failed to initialize cursor tracking; will retry: {error}");
|
eprintln!("failed to initialize cursor tracking; will retry: {error}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ pub struct CursorPositionChanged {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CursorState(RwLock<HashMap<String, CursorPositions>>);
|
pub(crate) struct CursorState(RwLock<HashMap<String, CursorPositions>>);
|
||||||
|
|
||||||
impl CursorState {
|
impl CursorState {
|
||||||
fn update(
|
fn update(
|
||||||
@@ -113,8 +113,12 @@ lazy_static! {
|
|||||||
pub static ref CURSOR_TASK: Mutex<Option<CursorTask>> = Mutex::new(None);
|
pub static ref CURSOR_TASK: Mutex<Option<CursorTask>> = Mutex::new(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize cursor tracking.
|
pub fn init(app: &AppHandle) {
|
||||||
pub fn init(app: &AppHandle) -> Result<(), String> {
|
app.manage(CursorState::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starts cursor tracking after Accessibility permission is available.
|
||||||
|
pub fn start_tracking(app: &AppHandle) -> Result<(), String> {
|
||||||
println!("init_cursor_tracking called");
|
println!("init_cursor_tracking called");
|
||||||
|
|
||||||
if !crate::macos::accessibility_permission_granted(app) {
|
if !crate::macos::accessibility_permission_granted(app) {
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ impl SeenInteractions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct InteractionState(Mutex<SeenInteractions>);
|
pub(crate) struct InteractionState(Mutex<SeenInteractions>);
|
||||||
|
|
||||||
|
pub fn init(handle: &AppHandle) {
|
||||||
|
handle.manage(InteractionState::default());
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn receive(
|
pub(crate) fn receive(
|
||||||
handle: &AppHandle,
|
handle: &AppHandle,
|
||||||
|
|||||||
@@ -19,20 +19,17 @@ mod ui;
|
|||||||
mod updater;
|
mod updater;
|
||||||
mod user;
|
mod user;
|
||||||
|
|
||||||
use tauri::Manager;
|
|
||||||
|
|
||||||
async fn launch_app(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
async fn launch_app(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let handle = app.handle();
|
let handle = app.handle();
|
||||||
updater::init(handle).await;
|
updater::init(handle).await;
|
||||||
db::init(handle).await?;
|
db::init(handle).await?;
|
||||||
scene_configuration::init(handle).await?;
|
scene_configuration::init(handle).await?;
|
||||||
keypair::init(handle).await?;
|
keypair::init(handle).await?;
|
||||||
app.manage(interactions::InteractionState::default());
|
interactions::init(handle);
|
||||||
app.manage(ufa::ForegroundAppState::default());
|
|
||||||
app.manage(cursor::CursorState::default());
|
|
||||||
app.manage(puppet::PuppetStateStore::default());
|
|
||||||
network::init(handle).await?;
|
|
||||||
ufa::init(handle);
|
ufa::init(handle);
|
||||||
|
cursor::init(handle);
|
||||||
|
network::init(handle).await?;
|
||||||
|
ufa::start(handle);
|
||||||
puppet::init(handle)?;
|
puppet::init(handle)?;
|
||||||
application::init(handle).await?;
|
application::init(handle).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub struct PuppetStatesChanged {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PuppetStateStore(RwLock<HashMap<String, PuppetState>>);
|
pub(crate) struct PuppetStateStore(RwLock<HashMap<String, PuppetState>>);
|
||||||
|
|
||||||
impl PuppetStateStore {
|
impl PuppetStateStore {
|
||||||
fn update(
|
fn update(
|
||||||
@@ -75,6 +75,7 @@ pub fn list_puppet_states(state: State<'_, PuppetStateStore>) -> Result<Vec<Pupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(handle: &AppHandle) -> Result<(), String> {
|
pub fn init(handle: &AppHandle) -> Result<(), String> {
|
||||||
|
handle.manage(PuppetStateStore::default());
|
||||||
let monitor = handle
|
let monitor = handle
|
||||||
.primary_monitor()
|
.primary_monitor()
|
||||||
.map_err(|error| error.to_string())?
|
.map_err(|error| error.to_string())?
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub struct FriendForegroundAppChanged {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ForegroundAppState(RwLock<HashMap<String, AppMeta>>);
|
pub(crate) struct ForegroundAppState(RwLock<HashMap<String, AppMeta>>);
|
||||||
|
|
||||||
impl ForegroundAppState {
|
impl ForegroundAppState {
|
||||||
fn update(&self, user_id: String, meta: AppMeta) -> Result<(), String> {
|
fn update(&self, user_id: String, meta: AppMeta) -> Result<(), String> {
|
||||||
@@ -103,10 +103,12 @@ where
|
|||||||
// no-op on unsupported platforms
|
// no-op on unsupported platforms
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes the foreground app change listener
|
|
||||||
/// and emits events to the Tauri app on changes.
|
|
||||||
/// Used for app to emit user foreground app to peers.
|
|
||||||
pub fn init(handle: &AppHandle) {
|
pub fn init(handle: &AppHandle) {
|
||||||
|
handle.manage(ForegroundAppState::default());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starts the foreground app change listener after network state is available.
|
||||||
|
pub fn start(handle: &AppHandle) {
|
||||||
update_local_app(handle, current_app());
|
update_local_app(handle, current_app());
|
||||||
let handle = handle.clone();
|
let handle = handle.clone();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user