fix(scheduler): wire post queue action on stop time and remove unused field warning

This commit is contained in:
NimBold
2026-06-15 11:13:11 +03:30
parent e7608dc8b4
commit 2ddcd2d99a
2 changed files with 12 additions and 19 deletions
+6 -2
View File
@@ -895,8 +895,7 @@ fn set_prevent_sleep(state: tauri::State<'_, AppState>, prevent: bool) {
}
}
#[tauri::command]
fn perform_system_action(action: crate::ipc::PostQueueAction) -> Result<(), String> {
pub(crate) fn execute_system_action(action: crate::ipc::PostQueueAction) -> Result<(), String> {
match action {
crate::ipc::PostQueueAction::Shutdown => {
system_shutdown::shutdown().map_err(|e| e.to_string())
@@ -911,6 +910,11 @@ fn perform_system_action(action: crate::ipc::PostQueueAction) -> Result<(), Stri
}
}
#[tauri::command]
fn perform_system_action(action: crate::ipc::PostQueueAction) -> Result<(), String> {
execute_system_action(action)
}
#[tauri::command]
async fn set_concurrent_limit(state: tauri::State<'_, AppState>, limit: usize) -> Result<(), String> {
let _ = rpc_call(
+6 -17
View File
@@ -1,23 +1,8 @@
use tauri::{Manager, Emitter};
use chrono::{Local, Datelike};
use std::time::Duration;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct SchedulerSettings {
enabled: bool,
#[serde(rename = "startTime")]
start_time: String,
#[serde(rename = "stopTimeEnabled")]
stop_time_enabled: bool,
#[serde(rename = "stopTime")]
stop_time: String,
everyday: bool,
#[serde(rename = "selectedDays")]
selected_days: Vec<u32>,
#[serde(rename = "postQueueAction")]
post_queue_action: String,
}
pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
tauri::async_runtime::spawn(async move {
@@ -33,7 +18,7 @@ pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
if let Some(settings_str) = settings_opt {
if let Ok(mut settings) = serde_json::from_str::<serde_json::Value>(&settings_str) {
if let Ok(scheduler) = serde_json::from_value::<SchedulerSettings>(settings.get("scheduler").unwrap_or(&serde_json::json!({})).clone()) {
if let Ok(scheduler) = serde_json::from_value::<crate::ipc::SchedulerSettings>(settings.get("scheduler").unwrap_or(&serde_json::json!({})).clone()) {
if !scheduler.enabled {
continue;
}
@@ -77,6 +62,10 @@ pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
let conn = state.conn.lock().unwrap();
let _ = crate::db::save_settings(&conn, &updated);
}
if !matches!(scheduler.post_queue_action, crate::ipc::PostQueueAction::None) {
let _ = crate::execute_system_action(scheduler.post_queue_action.clone());
}
}
}
}