diff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lock index d871d49b..e000d1d7 100644 --- a/apps/desktop/src-tauri/Cargo.lock +++ b/apps/desktop/src-tauri/Cargo.lock @@ -2595,6 +2595,7 @@ dependencies = [ "log", "objc", "serde", + "serde_json", "tauri", "tauri-build", "tauri-nspanel", @@ -3472,9 +3473,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "indexmap 2.2.6", "itoa 1.0.11", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 54c80c4d..fbb02daa 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -40,6 +40,7 @@ tauri = { version = "1.6.8", features = [ "http-all", ] } serde = { version = "1.0.203", features = ["derive"] } +serde_json = "1.0.120" tokio = { version = "1.38.0", features = [ "full", ] } # Required for asynchronous operations diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/config.rs new file mode 100644 index 00000000..b4565e16 --- /dev/null +++ b/apps/desktop/src-tauri/src/config.rs @@ -0,0 +1,39 @@ +use serde::{Deserialize, Serialize}; +use serde_json::json; +use tauri::{AppHandle, Manager}; +use tauri_plugin_store::StoreBuilder; + +#[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum WindowLayout { + Left, + Right, + Center, +} + +#[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct Config { + pub pin: bool, + pub placment: WindowLayout, + pub telemetry: bool, + pub join_history_notifications: bool, + pub show_only_talking_users: bool, +} + +// create a helper function to seed the config with values +pub fn create_config(app: &AppHandle) { + // create the store + let mut appdir = app.path_resolver().app_data_dir().unwrap(); + appdir.push("config_v2.json"); + + let mut store = StoreBuilder::new(app.app_handle(), appdir).build(); + store.insert("pin".to_string(), json!(false)); + store.insert("placement".to_string(), json!(WindowLayout::Center)); + store.insert("telemetry".to_string(), json!(true)); + store.insert("join_history_notifications".to_string(), json!(true)); + store.insert("show_only_talking_users".to_string(), json!(true)); + + store.save(); + println!("ayo"); +} diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index 58520988..88a5700c 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -9,11 +9,13 @@ extern crate objc; mod commands; +mod config; mod constants; mod tray; mod window_custom; use crate::commands::*; +use config::create_config; use constants::*; use log::LevelFilter; use log::{debug, info}; @@ -108,6 +110,10 @@ fn main() { // update the system tray Tray::update_tray(&app.app_handle()); + debug!("Updated the tray/taskbar menu"); + + // we should call this to create the config file + create_config(&app.app_handle()); info!("Started app"); Ok(())