mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-17 14:57:49 +00:00
fix(scheduler): wire post queue action on stop time and remove unused field warning
This commit is contained in:
@@ -895,8 +895,7 @@ fn set_prevent_sleep(state: tauri::State<'_, AppState>, prevent: bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
pub(crate) fn execute_system_action(action: crate::ipc::PostQueueAction) -> Result<(), String> {
|
||||||
fn perform_system_action(action: crate::ipc::PostQueueAction) -> Result<(), String> {
|
|
||||||
match action {
|
match action {
|
||||||
crate::ipc::PostQueueAction::Shutdown => {
|
crate::ipc::PostQueueAction::Shutdown => {
|
||||||
system_shutdown::shutdown().map_err(|e| e.to_string())
|
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]
|
#[tauri::command]
|
||||||
async fn set_concurrent_limit(state: tauri::State<'_, AppState>, limit: usize) -> Result<(), String> {
|
async fn set_concurrent_limit(state: tauri::State<'_, AppState>, limit: usize) -> Result<(), String> {
|
||||||
let _ = rpc_call(
|
let _ = rpc_call(
|
||||||
|
|||||||
@@ -1,23 +1,8 @@
|
|||||||
use tauri::{Manager, Emitter};
|
use tauri::{Manager, Emitter};
|
||||||
use chrono::{Local, Datelike};
|
use chrono::{Local, Datelike};
|
||||||
use std::time::Duration;
|
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) {
|
pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
|
||||||
tauri::async_runtime::spawn(async move {
|
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 Some(settings_str) = settings_opt {
|
||||||
if let Ok(mut settings) = serde_json::from_str::<serde_json::Value>(&settings_str) {
|
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 {
|
if !scheduler.enabled {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -77,6 +62,10 @@ pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
|
|||||||
let conn = state.conn.lock().unwrap();
|
let conn = state.conn.lock().unwrap();
|
||||||
let _ = crate::db::save_settings(&conn, &updated);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user