From b39c2719614731f7cb1fb0859bf2cf3385e07bac Mon Sep 17 00:00:00 2001 From: catto Date: Sun, 21 Apr 2024 14:52:57 +0200 Subject: [PATCH] check db init when starting --- src-tauri/src/main.rs | 11 +++++------ src/main.ts | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b9886af..1acebf6 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -6,10 +6,10 @@ use std::fs; use home::home_dir; use libsnotes::show_notes; -// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] -fn greet(name: &str) -> String { - format!("Hello, {}! You've been greeted from Rust!", name) +fn init_db() { + libsnotes::init_db().unwrap(); + println!("initted") } /// get ALL notes in the Database. If you don't want this, set show_notes(false) @@ -27,8 +27,7 @@ fn get_latest_note() -> String { #[tauri::command] fn get_note_by_id(id: u32) -> String { - let result = libsnotes::get_note_by_id(id).unwrap(); - result + libsnotes::get_note_by_id(id).unwrap() } #[tauri::command] @@ -93,7 +92,7 @@ fn init_settings() { fn main() { tauri::Builder::default() .invoke_handler(tauri::generate_handler![ - greet, + init_db, get_notes_list, get_latest_note, get_note_by_id, diff --git a/src/main.ts b/src/main.ts index 0d3cf34..fc11ace 100644 --- a/src/main.ts +++ b/src/main.ts @@ -116,6 +116,8 @@ async function retrieveNotes(): Promise> { window.addEventListener("DOMContentLoaded", async () => { // settings settings = await loadSettings(); + // db + await invoke("init_db"); console.log("ACTUAL SETTINGS IN FRONTEND: ", settings.fontSize) createNoteContentEl = document.querySelector("#create-input");