mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-04-21 21:24:05 +02:00
fix: reregister of hotkey not working
This commit is contained in:
parent
617c1737b7
commit
416e2f020d
4 changed files with 8 additions and 32 deletions
|
@ -24,32 +24,6 @@ pub async fn initialize_settings(pool: &SqlitePool) -> Result<(), Box<dyn std::e
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn save_keybind(
|
||||
app_handle: tauri::AppHandle,
|
||||
pool: tauri::State<'_, SqlitePool>,
|
||||
keybind: Vec<String>
|
||||
) -> Result<(), String> {
|
||||
app_handle.emit("update-shortcut", &keybind).map_err(|e| e.to_string())?;
|
||||
|
||||
let json = serde_json::to_string(&keybind).map_err(|e| e.to_string())?;
|
||||
|
||||
sqlx
|
||||
::query("INSERT OR REPLACE INTO settings (key, value) VALUES ('keybind', ?)")
|
||||
.bind(json)
|
||||
.execute(&*pool).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let _ = app_handle.track_event(
|
||||
"keybind_saved",
|
||||
Some(serde_json::json!({
|
||||
"keybind": keybind
|
||||
}))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_setting(
|
||||
pool: tauri::State<'_, SqlitePool>,
|
||||
|
@ -74,7 +48,7 @@ pub async fn save_setting(
|
|||
sqlx
|
||||
::query("INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)")
|
||||
.bind(key.clone())
|
||||
.bind(value)
|
||||
.bind(value.clone())
|
||||
.execute(&*pool).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
|
@ -85,6 +59,10 @@ pub async fn save_setting(
|
|||
}))
|
||||
);
|
||||
|
||||
if key == "keybind" {
|
||||
let _ = app_handle.emit("update-shortcut", &value).map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue