Refactoring code, fixing name and adding readme

This commit is contained in:
xyroscar
2024-11-06 20:17:03 +05:30
parent 2e29a1cb82
commit dbedae1f58
10 changed files with 102 additions and 25 deletions

View File

View File

@@ -3,3 +3,17 @@ mod collection;
pub use workspace::*;
pub use collection::*;
pub fn handlers() -> impl Fn(tauri::ipc::Invoke) -> bool {
tauri::generate_handler![
create_workspace,
get_workspaces,
get_workspace,
update_workspace,
delete_workspace,
create_collection,
get_workspace_collections,
update_collection,
delete_collection
]
}

View File

@@ -1,13 +1,15 @@
mod api;
mod models;
mod storage;
mod commands;
mod client;
use commands::handlers as h;
use storage::Storage;
use tauri::Manager;
use std::sync::Mutex;
fn main() {
let handlers = h();
tauri::Builder::default()
.setup(|app| {
let app_dir = app.path().app_data_dir()
@@ -19,17 +21,7 @@ fn main() {
app.manage(Mutex::new(storage));
Ok(())
})
.invoke_handler(tauri::generate_handler![
commands::create_workspace,
commands::get_workspaces,
commands::get_workspace,
commands::update_workspace,
commands::delete_workspace,
commands::create_collection,
commands::get_workspace_collections,
commands::update_collection,
commands::delete_collection,
])
.invoke_handler(handlers)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
}

View File

@@ -59,7 +59,7 @@ pub struct Storage {
impl Storage {
pub fn new(app_dir: PathBuf) -> rusqlite::Result<Self> {
let db_path = app_dir.join("api-client.db");
let db_path = app_dir.join("resona.db");
let data_dir = app_dir.join("data");
fs::create_dir_all(&data_dir).map_err(|e| rusqlite::Error::InvalidPath(data_dir.clone()))?;