fixed state/manage issues

This commit is contained in:
PandaDEV 2024-09-02 21:28:10 +10:00
parent 78235f0e3d
commit 59d31ce5d9
No known key found for this signature in database
GPG key ID: 13EFF9BAF70EE75C
3 changed files with 5 additions and 7 deletions

View file

@ -135,7 +135,9 @@ pub async fn save_keybind(
}
#[tauri::command]
pub async fn get_keybind(pool: State<'_, SqlitePool>) -> Result<Vec<String>, String> {
pub async fn get_keybind(app_handle: tauri::AppHandle) -> Result<Vec<String>, String> {
let pool = app_handle.state::<SqlitePool>();
let result = sqlx::query_scalar::<_, String>(
"SELECT value FROM settings WHERE key = 'keybind'"
)

View file

@ -10,10 +10,7 @@ fn key_to_string(key: &Key) -> String {
#[warn(dead_code)]
pub fn setup(app_handle: tauri::AppHandle) {
std::thread::spawn(move || {
let pool = app_handle.state::<sqlx::SqlitePool>();
let rt = app_handle.state::<tokio::runtime::Runtime>();
let keybind = rt.block_on(async { get_keybind(pool).await.unwrap_or_default() });
let keybind = tauri::async_runtime::block_on(async { get_keybind(app_handle.clone()).await.unwrap_or_default() });
println!("Listening for keybind: {:?}", keybind);