Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Igigog committed Oct 22, 2023
1 parent fd2077f commit 13f2153
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ use tauri::Manager;
use window_shadows::set_shadow;

// Logging
use log::{debug, error, info, warn};
use log::{error, info, warn};
extern crate simplelog;
use simplelog::*;
use std::fs;
use std::fs::File;
use tauri::PathResolver;

mod commands;
mod model;
Expand Down Expand Up @@ -304,17 +303,19 @@ fn send_cmd(
fn write_config(
config: Config,
connection_state: State<'_, Mutex<ConnectionState>>,
) -> Result<bool, String> {
) -> Result<(), String> {
let prep = SetPreprocessingConfiguration::new(&config.preprocessing);
let filters = SetFilterConfiguration::new(&config.filters);
let codec = SetPcm3060Configuration::new(&config.codec);
let cmd = SetConfiguration::new(prep, filters, codec);
send_cmd(connection_state, cmd).map(|_| true)
send_cmd(connection_state, cmd)?;
Ok(())
}

#[tauri::command]
fn save_config(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<bool, String> {
send_cmd(connection_state, SaveConfiguration::new()).map(|_| true)
fn save_config(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<(), String> {
send_cmd(connection_state, SaveConfiguration::new())?;
Ok(())
}

#[tauri::command]
Expand Down Expand Up @@ -379,8 +380,9 @@ fn load_config(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<Co
}

#[tauri::command]
fn factory_reset(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<bool, String> {
send_cmd(connection_state, FactoryReset::new()).map(|_| true)
fn factory_reset(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<(), String> {
send_cmd(connection_state, FactoryReset::new())?;
Ok(())
}

#[tauri::command]
Expand All @@ -401,7 +403,7 @@ fn reboot_bootloader(connection_state: State<Mutex<ConnectionState>>) -> Result<
);
info!("Reboot Device: {}", r.is_err());

return Ok(());
Ok(())
}

#[tauri::command]
Expand Down Expand Up @@ -464,7 +466,7 @@ fn open(
None => continue,
}
}
return Err("Unknown error".to_owned());
Err("Unknown error".to_owned())
}

#[tauri::command]
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Filter {

pub fn payload(&self) -> Vec<u8> {
let mut filter_payload = Vec::new();
filter_payload.push(self.discriminant() as u8);
filter_payload.push(self.discriminant());
filter_payload.extend_from_slice(&[0u8; 3]);

match self {
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default {
}
}
invoke('write_config', { config: sendConfig }).then((message) => {})
invoke('write_config', { config: sendConfig }).then(() => {})
}
}, 5),
saveState: debounce(function () {
Expand Down

0 comments on commit 13f2153

Please sign in to comment.