Skip to content

Commit

Permalink
ayo
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore committed Sep 4, 2024
1 parent bc42ce8 commit 703a426
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
25 changes: 21 additions & 4 deletions apps/desktop/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -71,15 +71,26 @@ pub fn open_devtools(window: WebviewWindow) {
}

#[tauri::command]
pub fn toggle_pin(window: WebviewWindow, pin: State<Pinned>, menu: State<TrayMenu>, config: State<StoreWrapper>) {
pub fn toggle_pin(
window: WebviewWindow,
pin: State<Pinned>,
menu: State<TrayMenu>,
config: State<StoreWrapper>,
) {
let app = window.app_handle();
let value = !get_pin(app.state::<Pinned>());

_set_pin(value, &window, pin, menu, config);
}

#[tauri::command]
pub fn set_pin(window: WebviewWindow, pin: State<Pinned>, menu: State<TrayMenu>, value: bool, config: State<StoreWrapper>) {
pub fn set_pin(
window: WebviewWindow,
pin: State<Pinned>,
menu: State<TrayMenu>,
value: bool,
config: State<StoreWrapper>,
) {
_set_pin(value, &window, pin, menu, config);
}

Expand Down Expand Up @@ -107,7 +118,13 @@ impl Deref for TrayMenu {
}
}

fn _set_pin(value: bool, window: &WebviewWindow, pinned: State<Pinned>, menu: State<TrayMenu>, config: State<StoreWrapper>) {
fn _set_pin(
value: bool,
window: &WebviewWindow,
pinned: State<Pinned>,
menu: State<TrayMenu>,
config: State<StoreWrapper>,
) {
// @d0nutptr cooked here
pinned.store(value, std::sync::atomic::Ordering::Relaxed);

Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,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;
Expand Down Expand Up @@ -136,7 +136,7 @@ fn main() {
// NOTE: this might be a bug?
window.set_decorations(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)));

Expand Down

0 comments on commit 703a426

Please sign in to comment.