From 2a8cafdd07ea2717a2eb353dc8f4bc9801caf193 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:44:32 -0500 Subject: [PATCH 1/7] Progress --- apps/desktop/src-tauri/Cargo.lock | 16 +++++++ apps/desktop/src-tauri/Cargo.toml | 1 + apps/desktop/src-tauri/src/commands.rs | 29 +++++++++--- apps/desktop/src-tauri/src/config.rs | 62 ++++++++++++++++++++++++++ apps/desktop/src-tauri/src/main.rs | 10 ++++- apps/desktop/src-tauri/src/tray.rs | 6 +-- turbo.json | 1 + 7 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 apps/desktop/src-tauri/src/config.rs diff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lock index 9e700cc5..1a04cf51 100644 --- a/apps/desktop/src-tauri/Cargo.lock +++ b/apps/desktop/src-tauri/Cargo.lock @@ -2738,6 +2738,7 @@ dependencies = [ "tauri-plugin-process", "tauri-plugin-shell", "tauri-plugin-single-instance", + "tauri-plugin-store", "tauri-plugin-updater", "tauri-plugin-websocket", "tauri-plugin-window-state", @@ -4510,6 +4511,21 @@ dependencies = [ "zbus", ] +[[package]] +name = "tauri-plugin-store" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e54ba1a0c0c60a6a08e711e184239f8a50354988b6fe1af8b5ce2215b2e79a2" +dependencies = [ + "dunce", + "log", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "thiserror", +] + [[package]] name = "tauri-plugin-updater" version = "2.0.0-rc.3" diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 5f488fdc..7a261821 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -36,6 +36,7 @@ tauri-plugin-os = "2.0.0-rc.1" tauri-plugin-http = "2.0.0-rc.4" tauri-plugin-log = "2.0.0-rc.2" tauri-plugin-notification = "2.0.0-rc.5" +tauri-plugin-store = "2.0.0-rc" anyhow = "1.0.86" log = "0.4.22" diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 5cdb1cbf..18726996 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -3,9 +3,11 @@ use std::{ sync::{atomic::AtomicBool, Mutex}, }; +use serde_json::json; use tauri::{image::Image, menu::Menu, AppHandle, Emitter, Manager, State, WebviewWindow, Wry}; +use tauri_plugin_store::{Store, StoreCollection}; -use crate::{constants::*, Pinned, TrayMenu}; +use crate::{constants::*, Pinned, StoreWrapper, TrayMenu}; #[tauri::command] pub fn open_settings(window: WebviewWindow, update: bool) { @@ -34,7 +36,7 @@ pub fn close_settings(window: WebviewWindow) { #[tauri::command] pub fn get_pin(storage: State) -> bool { - storage.0.load(std::sync::atomic::Ordering::Relaxed) + storage.load(std::sync::atomic::Ordering::Relaxed) } #[tauri::command] @@ -43,16 +45,16 @@ pub fn open_devtools(window: WebviewWindow) { } #[tauri::command] -pub fn toggle_pin(window: WebviewWindow, pin: State, menu: State) { +pub fn toggle_pin(window: WebviewWindow, pin: State, menu: State, config: State) { let app = window.app_handle(); let value = !get_pin(app.state::()); - _set_pin(value, &window, pin, menu); + _set_pin(value, &window, pin, menu, config); } #[tauri::command] -pub fn set_pin(window: WebviewWindow, pin: State, menu: State, value: bool) { - _set_pin(value, &window, pin, menu); +pub fn set_pin(window: WebviewWindow, pin: State, menu: State, value: bool, config: State) { + _set_pin(value, &window, pin, menu, config); } impl Deref for Pinned { @@ -63,6 +65,14 @@ impl Deref for Pinned { } } +impl Deref for StoreWrapper { + type Target = Mutex>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + impl Deref for TrayMenu { type Target = Mutex>; @@ -71,7 +81,7 @@ impl Deref for TrayMenu { } } -fn _set_pin(value: bool, window: &WebviewWindow, pinned: State, menu: State) { +fn _set_pin(value: bool, window: &WebviewWindow, pinned: State, menu: State, config: State) { // @d0nutptr cooked here pinned.store(value, std::sync::atomic::Ordering::Relaxed); @@ -103,6 +113,11 @@ fn _set_pin(value: bool, window: &WebviewWindow, pinned: State, menu: St } }); + if let Ok(mut c) = config.lock() { + c.insert("pin".to_owned(), json!(value)); + c.save(); + } + window.set_ignore_cursor_events(value); // update the tray icon diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/config.rs new file mode 100644 index 00000000..3dd314fa --- /dev/null +++ b/apps/desktop/src-tauri/src/config.rs @@ -0,0 +1,62 @@ +use log::debug; +use serde::{Deserialize, Serialize}; +use serde_json::json; +use tauri::{AppHandle, Manager, Wry}; +use tauri_plugin_store::{Store, StoreBuilder}; + +#[derive(Deserialize, Serialize, Debug, Copy, Clone)] +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum WindowLayout { + Left, + Right, + Center, +} + +#[derive(Deserialize, Serialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct FeatureFlags { + hide_overlay_on_mouseover: bool, +} + +#[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, + pub feature_flags: FeatureFlags, +} + +const CONFIG_FILE_NAME: &str = "expirmental_config_v2.json"; +// create a helper function to seed the config with values +pub fn create_or_get_config(app: &AppHandle) -> Store { + debug!("Creating or getting config..."); + // create the store + let mut appdir = app + .path() + .app_data_dir() + .expect("failed to get app data dir"); + appdir.push(CONFIG_FILE_NAME); + let config_exists = (appdir.clone()).exists(); + + let mut store = StoreBuilder::new(CONFIG_FILE_NAME).build(app.app_handle().clone()); + + // if the file exists we don't want to overwrite it + if config_exists { + debug!("Config file already exists, skipping creation"); + } else { + store.insert("pin".to_string(), json!(false)); + store.insert("placement".to_string(), json!(WindowLayout::Center)); + store.insert("telemetry".to_string(), json!(true)); + store.insert("joinHistoryNotifications".to_string(), json!(true)); + store.insert("showOnlyTalkingUsers".to_string(), json!(true)); + store.insert("featureFlags".to_string(), json!({})); + + store.save(); + debug!("Config file created successfully"); + } + + store +} diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index 8911c88f..f4801413 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -11,11 +11,14 @@ mod app_handle; mod commands; mod constants; mod tray; +mod config; mod window_custom; use crate::commands::*; +use config::create_or_get_config; use constants::*; use log::{debug, info}; +use tauri_plugin_store::Store; use std::{ str::FromStr, sync::{atomic::AtomicBool, Mutex}, @@ -39,7 +42,7 @@ use system_notification::WorkspaceListener; use tauri::WebviewWindow; pub struct Pinned(AtomicBool); - +pub struct StoreWrapper(Mutex>); pub struct TrayMenu(Mutex>); #[cfg(target_os = "macos")] @@ -95,6 +98,7 @@ fn main() { .plugin(window_state_plugin.build()) .plugin(tauri_plugin_websocket::init()) .plugin(tauri_plugin_fs::init()) + .plugin(tauri_plugin_store::Builder::default().build()) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_os::init()) @@ -133,6 +137,10 @@ fn main() { window.set_decorations(false); window.set_shadow(false); + // we should call this to create the config file + let config = create_or_get_config(&app.app_handle()); + app.manage(StoreWrapper(Mutex::new(config))); + // add mac things #[cfg(target_os = "macos")] apply_macos_specifics(&window); diff --git a/apps/desktop/src-tauri/src/tray.rs b/apps/desktop/src-tauri/src/tray.rs index cb775ed8..0bc53a5a 100644 --- a/apps/desktop/src-tauri/src/tray.rs +++ b/apps/desktop/src-tauri/src/tray.rs @@ -10,9 +10,7 @@ use anyhow::Result; use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use crate::{ - commands, toggle_pin, Pinned, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, SETTINGS_WINDOW_NAME, - TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, TRAY_RELOAD, TRAY_SETTINGS, - TRAY_SHOW_APP, TRAY_TOGGLE_PIN, + commands, toggle_pin, Pinned, StoreWrapper, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, SETTINGS_WINDOW_NAME, TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, TRAY_RELOAD, TRAY_SETTINGS, TRAY_SHOW_APP, TRAY_TOGGLE_PIN }; pub struct Tray; @@ -52,7 +50,7 @@ impl Tray { TRAY_TOGGLE_PIN => { let window = app.get_webview_window(MAIN_WINDOW_NAME).unwrap(); - toggle_pin(window, app.state::(), app.state::()) + toggle_pin(window, app.state::(), app.state::(), app.state::()); } TRAY_SHOW_APP => { let window = app.get_webview_window(MAIN_WINDOW_NAME).unwrap(); diff --git a/turbo.json b/turbo.json index 5a9122f2..064811ea 100644 --- a/turbo.json +++ b/turbo.json @@ -11,6 +11,7 @@ "TAURI_SIGNING_PRIVATE_KEY", "TAURI_SIGNING_PUBLIC_KEY", "VITE_AXIOM_TOKEN", + "LOG_LEVEL", "R2_ACCOUNT_ID", "R2_ACCESS_KEY_ID", "R2_SECRET_ACCESS_KEY", From 4c4d6d510a46ee0766ff74603e1af14bfe668fa5 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:48:37 -0500 Subject: [PATCH 2/7] good lookin --- apps/desktop/src-tauri/src/config.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/config.rs index 3dd314fa..73f61720 100644 --- a/apps/desktop/src-tauri/src/config.rs +++ b/apps/desktop/src-tauri/src/config.rs @@ -45,7 +45,8 @@ pub fn create_or_get_config(app: &AppHandle) -> Store { // if the file exists we don't want to overwrite it if config_exists { - debug!("Config file already exists, skipping creation"); + debug!("Config file already exists, loading from file"); + store.load(); } else { store.insert("pin".to_string(), json!(false)); store.insert("placement".to_string(), json!(WindowLayout::Center)); From 4b4d91362b67e38d80a0cd31e17e95f856f2b894 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:56:29 -0500 Subject: [PATCH 3/7] Good looknin2 --- apps/desktop/src-tauri/src/config.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/config.rs index 73f61720..f1a2e0a9 100644 --- a/apps/desktop/src-tauri/src/config.rs +++ b/apps/desktop/src-tauri/src/config.rs @@ -41,7 +41,9 @@ pub fn create_or_get_config(app: &AppHandle) -> Store { appdir.push(CONFIG_FILE_NAME); let config_exists = (appdir.clone()).exists(); - let mut store = StoreBuilder::new(CONFIG_FILE_NAME).build(app.app_handle().clone()); + let mut store = StoreBuilder::new(CONFIG_FILE_NAME) + .serialize(|cache| serde_json::to_vec_pretty(&cache).map_err(Into::into)) + .build(app.app_handle().clone()); // if the file exists we don't want to overwrite it if config_exists { From eaec34cc677bd9a550631ffc8214c30cf89fc2f0 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Tue, 3 Sep 2024 20:59:19 -0500 Subject: [PATCH 4/7] ayo --- apps/desktop/src-tauri/src/commands.rs | 25 +++++++++++++++++++++---- apps/desktop/src-tauri/src/main.rs | 6 +++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 18726996..43f40f9b 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -5,7 +5,7 @@ use std::{ use serde_json::json; use tauri::{image::Image, menu::Menu, AppHandle, Emitter, Manager, State, WebviewWindow, Wry}; -use tauri_plugin_store::{Store, StoreCollection}; +use tauri_plugin_store::Store; use crate::{constants::*, Pinned, StoreWrapper, TrayMenu}; @@ -45,7 +45,12 @@ pub fn open_devtools(window: WebviewWindow) { } #[tauri::command] -pub fn toggle_pin(window: WebviewWindow, pin: State, menu: State, config: State) { +pub fn toggle_pin( + window: WebviewWindow, + pin: State, + menu: State, + config: State, +) { let app = window.app_handle(); let value = !get_pin(app.state::()); @@ -53,7 +58,13 @@ pub fn toggle_pin(window: WebviewWindow, pin: State, menu: State, menu: State, value: bool, config: State) { +pub fn set_pin( + window: WebviewWindow, + pin: State, + menu: State, + value: bool, + config: State, +) { _set_pin(value, &window, pin, menu, config); } @@ -81,7 +92,13 @@ impl Deref for TrayMenu { } } -fn _set_pin(value: bool, window: &WebviewWindow, pinned: State, menu: State, config: State) { +fn _set_pin( + value: bool, + window: &WebviewWindow, + pinned: State, + menu: State, + config: State, +) { // @d0nutptr cooked here pinned.store(value, std::sync::atomic::Ordering::Relaxed); diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index f4801413..e212d182 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -9,22 +9,22 @@ extern crate objc; mod app_handle; mod commands; +mod config; mod constants; mod tray; -mod config; mod window_custom; use crate::commands::*; use config::create_or_get_config; use constants::*; use log::{debug, info}; -use tauri_plugin_store::Store; use std::{ str::FromStr, sync::{atomic::AtomicBool, Mutex}, }; use tauri::{generate_handler, menu::Menu, LogicalSize, Manager, Wry}; use tauri_plugin_log::{Target, TargetKind}; +use tauri_plugin_store::Store; use tauri_plugin_window_state::StateFlags; use tray::Tray; use window_custom::WebviewWindowExt; @@ -137,7 +137,7 @@ fn main() { window.set_decorations(false); window.set_shadow(false); - // we should call this to create the config file + // we should call this to create the config file let config = create_or_get_config(&app.app_handle()); app.manage(StoreWrapper(Mutex::new(config))); From 35d763fcc82447d684da988a1a1aaf6e0fac0be3 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:03:08 -0500 Subject: [PATCH 5/7] Format --- apps/desktop/src-tauri/src/tray.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src-tauri/src/tray.rs b/apps/desktop/src-tauri/src/tray.rs index 0bc53a5a..9419a892 100644 --- a/apps/desktop/src-tauri/src/tray.rs +++ b/apps/desktop/src-tauri/src/tray.rs @@ -10,7 +10,9 @@ use anyhow::Result; use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use crate::{ - commands, toggle_pin, Pinned, StoreWrapper, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, SETTINGS_WINDOW_NAME, TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, TRAY_RELOAD, TRAY_SETTINGS, TRAY_SHOW_APP, TRAY_TOGGLE_PIN + commands, toggle_pin, Pinned, StoreWrapper, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, + SETTINGS_WINDOW_NAME, TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, + TRAY_RELOAD, TRAY_SETTINGS, TRAY_SHOW_APP, TRAY_TOGGLE_PIN, }; pub struct Tray; @@ -50,7 +52,12 @@ impl Tray { TRAY_TOGGLE_PIN => { let window = app.get_webview_window(MAIN_WINDOW_NAME).unwrap(); - toggle_pin(window, app.state::(), app.state::(), app.state::()); + toggle_pin( + window, + app.state::(), + app.state::(), + app.state::(), + ); } TRAY_SHOW_APP => { let window = app.get_webview_window(MAIN_WINDOW_NAME).unwrap(); From b9b730e20d0bc27eba279ce050f9137a202eb19b Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:20:19 -0500 Subject: [PATCH 6/7] Rename --- .../src/{config.rs => app_settings.rs} | 28 ++++++++++++++++--- apps/desktop/src-tauri/src/commands.rs | 12 ++++---- apps/desktop/src-tauri/src/main.rs | 10 +++---- apps/desktop/src-tauri/src/tray.rs | 4 +-- 4 files changed, 37 insertions(+), 17 deletions(-) rename apps/desktop/src-tauri/src/{config.rs => app_settings.rs} (71%) diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/app_settings.rs similarity index 71% rename from apps/desktop/src-tauri/src/config.rs rename to apps/desktop/src-tauri/src/app_settings.rs index f1a2e0a9..0da4bf37 100644 --- a/apps/desktop/src-tauri/src/config.rs +++ b/apps/desktop/src-tauri/src/app_settings.rs @@ -20,7 +20,7 @@ pub struct FeatureFlags { #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct Config { +pub struct Settings { pub pin: bool, pub placment: WindowLayout, pub telemetry: bool, @@ -29,10 +29,26 @@ pub struct Config { pub feature_flags: FeatureFlags, } -const CONFIG_FILE_NAME: &str = "expirmental_config_v2.json"; +// create a default config +impl Default for Settings { + fn default() -> Self { + Settings { + pin: false, + placment: WindowLayout::Center, + telemetry: true, + join_history_notifications: true, + show_only_talking_users: true, + feature_flags: FeatureFlags { + hide_overlay_on_mouseover: false, + }, + } + } +} + +const CONFIG_FILE_NAME: &str = "experimental_config.json"; // create a helper function to seed the config with values -pub fn create_or_get_config(app: &AppHandle) -> Store { - debug!("Creating or getting config..."); +pub fn get_app_settings(app: &AppHandle) -> Store { + debug!("Creating or getting app settings..."); // create the store let mut appdir = app .path() @@ -48,8 +64,12 @@ pub fn create_or_get_config(app: &AppHandle) -> Store { // if the file exists we don't want to overwrite it if config_exists { debug!("Config file already exists, loading from file"); + // NOTE: we can get the config from the filesystem store.load(); + + // add keys from the default confg } else { + // NOTE: we need to create the config for the first time store.insert("pin".to_string(), json!(false)); store.insert("placement".to_string(), json!(WindowLayout::Center)); store.insert("telemetry".to_string(), json!(true)); diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 43f40f9b..6021b1a1 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -7,7 +7,7 @@ use serde_json::json; use tauri::{image::Image, menu::Menu, AppHandle, Emitter, Manager, State, WebviewWindow, Wry}; use tauri_plugin_store::Store; -use crate::{constants::*, Pinned, StoreWrapper, TrayMenu}; +use crate::{constants::*, Pinned, AppSettings, TrayMenu}; #[tauri::command] pub fn open_settings(window: WebviewWindow, update: bool) { @@ -49,7 +49,7 @@ pub fn toggle_pin( window: WebviewWindow, pin: State, menu: State, - config: State, + config: State, ) { let app = window.app_handle(); let value = !get_pin(app.state::()); @@ -63,9 +63,9 @@ pub fn set_pin( pin: State, menu: State, value: bool, - config: State, + settings: State, ) { - _set_pin(value, &window, pin, menu, config); + _set_pin(value, &window, pin, menu, settings); } impl Deref for Pinned { @@ -76,7 +76,7 @@ impl Deref for Pinned { } } -impl Deref for StoreWrapper { +impl Deref for AppSettings { type Target = Mutex>; fn deref(&self) -> &Self::Target { @@ -97,7 +97,7 @@ fn _set_pin( window: &WebviewWindow, pinned: State, menu: State, - config: State, + config: State, ) { // @d0nutptr cooked here pinned.store(value, std::sync::atomic::Ordering::Relaxed); diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index e212d182..aaa17c06 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -9,13 +9,13 @@ extern crate objc; mod app_handle; mod commands; -mod config; +mod app_settings; mod constants; mod tray; mod window_custom; use crate::commands::*; -use config::create_or_get_config; +use app_settings::get_app_settings; use constants::*; use log::{debug, info}; use std::{ @@ -42,7 +42,7 @@ use system_notification::WorkspaceListener; use tauri::WebviewWindow; pub struct Pinned(AtomicBool); -pub struct StoreWrapper(Mutex>); +pub struct AppSettings(Mutex>); pub struct TrayMenu(Mutex>); #[cfg(target_os = "macos")] @@ -138,8 +138,8 @@ fn main() { window.set_shadow(false); // we should call this to create the config file - let config = create_or_get_config(&app.app_handle()); - app.manage(StoreWrapper(Mutex::new(config))); + let app_settings = get_app_settings(&app.app_handle()); + app.manage(AppSettings(Mutex::new(app_settings))); // add mac things #[cfg(target_os = "macos")] diff --git a/apps/desktop/src-tauri/src/tray.rs b/apps/desktop/src-tauri/src/tray.rs index 9419a892..850e4d2e 100644 --- a/apps/desktop/src-tauri/src/tray.rs +++ b/apps/desktop/src-tauri/src/tray.rs @@ -10,7 +10,7 @@ use anyhow::Result; use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use crate::{ - commands, toggle_pin, Pinned, StoreWrapper, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, + commands, toggle_pin, Pinned, AppSettings, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, SETTINGS_WINDOW_NAME, TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, TRAY_RELOAD, TRAY_SETTINGS, TRAY_SHOW_APP, TRAY_TOGGLE_PIN, }; @@ -56,7 +56,7 @@ impl Tray { window, app.state::(), app.state::(), - app.state::(), + app.state::(), ); } TRAY_SHOW_APP => { From 4e1870b348d6640ff8c418a098b80166cc0897c6 Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:32:53 -0500 Subject: [PATCH 7/7] Format --- apps/desktop/src-tauri/src/app_settings.rs | 2 +- apps/desktop/src-tauri/src/commands.rs | 2 +- apps/desktop/src-tauri/src/main.rs | 2 +- apps/desktop/src-tauri/src/tray.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src-tauri/src/app_settings.rs b/apps/desktop/src-tauri/src/app_settings.rs index 0da4bf37..bf6477e4 100644 --- a/apps/desktop/src-tauri/src/app_settings.rs +++ b/apps/desktop/src-tauri/src/app_settings.rs @@ -29,7 +29,7 @@ pub struct Settings { pub feature_flags: FeatureFlags, } -// create a default config +// create a default config impl Default for Settings { fn default() -> Self { Settings { diff --git a/apps/desktop/src-tauri/src/commands.rs b/apps/desktop/src-tauri/src/commands.rs index 6021b1a1..dba1fba0 100644 --- a/apps/desktop/src-tauri/src/commands.rs +++ b/apps/desktop/src-tauri/src/commands.rs @@ -7,7 +7,7 @@ use serde_json::json; use tauri::{image::Image, menu::Menu, AppHandle, Emitter, Manager, State, WebviewWindow, Wry}; use tauri_plugin_store::Store; -use crate::{constants::*, Pinned, AppSettings, TrayMenu}; +use crate::{constants::*, AppSettings, Pinned, TrayMenu}; #[tauri::command] pub fn open_settings(window: WebviewWindow, update: bool) { diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index aaa17c06..bc7e2d8c 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -8,8 +8,8 @@ extern crate objc; mod app_handle; -mod commands; mod app_settings; +mod commands; mod constants; mod tray; mod window_custom; diff --git a/apps/desktop/src-tauri/src/tray.rs b/apps/desktop/src-tauri/src/tray.rs index 850e4d2e..b7f9c74e 100644 --- a/apps/desktop/src-tauri/src/tray.rs +++ b/apps/desktop/src-tauri/src/tray.rs @@ -10,7 +10,7 @@ use anyhow::Result; use tauri_plugin_window_state::{AppHandleExt, StateFlags}; use crate::{ - commands, toggle_pin, Pinned, AppSettings, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, + commands, toggle_pin, AppSettings, Pinned, TrayMenu, MAIN_WINDOW_NAME, OVERLAYED, SETTINGS_WINDOW_NAME, TRAY_OPEN_DEVTOOLS_MAIN, TRAY_OPEN_DEVTOOLS_SETTINGS, TRAY_QUIT, TRAY_RELOAD, TRAY_SETTINGS, TRAY_SHOW_APP, TRAY_TOGGLE_PIN, };