mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-26 12:08:27 +00:00
fix: resolve scheduler infinite loop and frozen delete modal bugs
This commit is contained in:
@@ -35,8 +35,10 @@ pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
|
||||
state.insert("schedulerLastStartKey".to_string(), serde_json::json!(key));
|
||||
state.insert("schedulerRunning".to_string(), serde_json::json!(true));
|
||||
});
|
||||
|
||||
let _ = app_handle.emit("schedule-trigger", "start");
|
||||
let _ = app_handle.emit("schedule-trigger", serde_json::json!({
|
||||
"action": "start",
|
||||
"key": key
|
||||
}));
|
||||
}
|
||||
|
||||
if scheduler.stop_time_enabled
|
||||
@@ -48,8 +50,10 @@ pub fn spawn_scheduler(app_handle: tauri::AppHandle) {
|
||||
state.insert("schedulerLastStopKey".to_string(), serde_json::json!(key));
|
||||
state.insert("schedulerRunning".to_string(), serde_json::json!(false));
|
||||
});
|
||||
|
||||
let _ = app_handle.emit("schedule-trigger", "stop");
|
||||
let _ = app_handle.emit("schedule-trigger", serde_json::json!({
|
||||
"action": "stop",
|
||||
"key": key
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -218,10 +218,13 @@ function App() {
|
||||
useEffect(() => {
|
||||
const unlisten = listen('schedule-trigger', async (event) => {
|
||||
const state = useSettingsStore.getState();
|
||||
if (event.payload === 'start') {
|
||||
const payload = event.payload as any;
|
||||
if (payload.action === 'start') {
|
||||
state.setSchedulerLastStartKey(payload.key);
|
||||
const started = await useDownloadStore.getState().startQueue(MAIN_QUEUE_ID);
|
||||
state.setSchedulerRunning(started > 0);
|
||||
} else if (event.payload === 'stop') {
|
||||
} else if (payload.action === 'stop') {
|
||||
state.setSchedulerLastStopKey(payload.key);
|
||||
await useDownloadStore.getState().pauseQueue(MAIN_QUEUE_ID);
|
||||
state.setSchedulerRunning(false);
|
||||
}
|
||||
|
||||
@@ -180,15 +180,19 @@ export default function SchedulerView() {
|
||||
<WindowDragRegion />
|
||||
|
||||
<div className="flex items-center gap-3 border-b border-border-color px-6 pb-4">
|
||||
<label className="flex items-center gap-3 text-[17px] font-semibold tracking-tight text-text-primary">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={draft.enabled}
|
||||
onChange={event => updateDraft('enabled', event.target.checked)}
|
||||
className="h-4 w-4 accent-accent"
|
||||
/>
|
||||
<div className="flex items-center gap-3 text-[17px] font-semibold tracking-tight text-text-primary">
|
||||
<button
|
||||
onClick={() => updateDraft('enabled', !draft.enabled)}
|
||||
className={`relative inline-flex h-5 w-9 cursor-pointer items-center rounded-full transition-colors duration-200 ease-in-out focus:outline-none ${draft.enabled ? 'bg-accent' : 'bg-item-hover'}`}
|
||||
aria-checked={draft.enabled}
|
||||
role="switch"
|
||||
>
|
||||
<span
|
||||
className={`inline-block h-4 w-4 transform rounded-full bg-white transition duration-200 ease-in-out ${draft.enabled ? 'translate-x-4' : 'translate-x-1'}`}
|
||||
/>
|
||||
</button>
|
||||
Scheduler
|
||||
</label>
|
||||
</div>
|
||||
<span className={`rounded-full px-2.5 py-1 text-[11px] font-semibold ${
|
||||
schedulerRunning ? 'bg-green-500/15 text-green-500' : 'bg-item-hover text-text-muted'
|
||||
}`}>
|
||||
|
||||
@@ -383,8 +383,7 @@ export const useDownloadStore = create<DownloadState>((set, get) => ({
|
||||
try {
|
||||
await invoke('remove_download', { id, filepath: null });
|
||||
} catch (e) {
|
||||
console.error("Failed to terminate download on deletion:", e);
|
||||
throw e;
|
||||
console.error("Failed to terminate download on backend during deletion, but will still remove from UI:", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user