feat(qconnect): write-through last_known_state on connect/disconnect

When startup_mode == RememberLast, persist the latest on/off state so
the next launch can restore it. No-op for Off/On modes.

cc
This commit is contained in:
vicrodh committed 2026-05-01 13:10:39 -06:00
1 parent 7bbe68d5b0
commit a6fb1cd018
1 file changed
+20 -3
+20 -3
View File
@@ -108,17 +108,34 @@ pub async fn v2_qconnect_connect(
.await
.map_err(RuntimeError::Internal)?;
service
let result = service
.connect(app_handle, core_bridge.0.clone(), config)
.await
.map_err(RuntimeError::Internal)
.map_err(RuntimeError::Internal);
// Write-through last_known_state when mode == RememberLast.
if result.is_ok()
&& super::startup::load_startup_mode() == QconnectStartupMode::RememberLast
{
super::startup::save_last_known_state(true);
}
result
}
#[tauri::command]
pub async fn v2_qconnect_disconnect(
service: State<'_, QconnectServiceState>,
) -> Result<QconnectConnectionStatus, RuntimeError> {
service.disconnect().await.map_err(RuntimeError::Internal)
let result = service.disconnect().await.map_err(RuntimeError::Internal);
if result.is_ok()
&& super::startup::load_startup_mode() == QconnectStartupMode::RememberLast
{
super::startup::save_last_known_state(false);
}
result
}
#[tauri::command]