Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend #12

Merged
merged 17 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions data_json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[
{
"name": "Default",
"icon": "i",
"macros": [
{
"name": "Macro Name",
"sequence": [],
"trigger": {
"type": "KeyPressEvent",
"data": [
{
"keypress": 7,
"press_duration": 0
}
]
},
"active": true
}
],
"active": true
},
{
"name": "OMGF",
"icon": "i",
"macros": [],
"active": false
},
{
"name": "HAHA",
"icon": "i",
"macros": [],
"active": false
},
{
"name": "test",
"icon": "i",
"macros": [],
"active": false
},
{
"name": "ADASD",
"icon": "i",
"macros": [],
"active": false
}
]
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"dependencies": {
"@chakra-ui/icons": "^2.0.11",
"@chakra-ui/react": "^2.3.6",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@tauri-apps/api": "^1.1.0",
"framer-motion": "^6",
"framer-motion": "^7.6.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"wouter": "^2.8.0-alpha.2"
Expand Down
114 changes: 0 additions & 114 deletions src-tauri/data_json.json

This file was deleted.

49 changes: 33 additions & 16 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ extern crate core;

use std::fs::File;
use std::io::Read;
use std::sync::RwLock;

use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json;
use tauri::App;
Expand All @@ -27,30 +29,24 @@ pub struct ApplicationConfig {
pub startup_delay: u64,
}

lazy_static! {
pub static ref APPLICATION_STATE: MacroDataState = {
MacroDataState::new()
};
}

fn main() {
tauri::Builder::default()
// This is where you pass in your commands
.manage(MacroDataState::new())
.invoke_handler(tauri::generate_handler![
export_frontend,
import_frontend,
push_frontend_first
get_configuration,
set_configuration
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

let mut config: ApplicationConfig = ApplicationConfig {
use_input_grab: false,
startup_delay: 3,
};

let mut file = match File::open("config.json") {
Ok(T) => T,
Err(E) => {
eprintln!("Error parsing the file {}", E);
println!("Error finding the config.json file.\nPlease place one in the root directory. Using default configuration (safe).\nCreating an empty file.\n");
File::create("config.json").unwrap()
}
};
// let mut data = String::new();
//
// match file.read_to_string(&mut data) {
Expand All @@ -64,5 +60,26 @@ fn main() {
// Err(E) => {}
// }

run_this(&config)



run_this(&get_config())
}


pub fn get_config() -> ApplicationConfig {
let mut config: ApplicationConfig = ApplicationConfig {
use_input_grab: false,
startup_delay: 3,
};

let mut file = match File::open("config.json") {
Ok(T) => T,
Err(E) => {
eprintln!("Error parsing the file {}", E);
println!("Error finding the config.json file.\nPlease place one in the root directory. Using default configuration (safe).\nCreating an empty file.\n");
File::create("config.json").unwrap()
}
};
config
}
Loading