mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): clarify scheduler logic
- use full conditional syntax with `{}` - do not mutate `action.payload` in a reducer
This commit is contained in:
parent
be8c0bb952
commit
f1a8b9daee
@ -24,14 +24,17 @@ const ParamScheduler = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedSchedulers.length === 0)
|
if (selectedSchedulers.length === 0) {
|
||||||
dispatch(setSelectedSchedulers([...SCHEDULER_ITEMS]));
|
dispatch(setSelectedSchedulers([...SCHEDULER_ITEMS]));
|
||||||
|
}
|
||||||
|
|
||||||
const schedulerFound = activeSchedulers.find(
|
const schedulerFound = activeSchedulers.find(
|
||||||
(activeSchedulers) => activeSchedulers.value === scheduler
|
(activeSchedulers) => activeSchedulers.value === scheduler
|
||||||
);
|
);
|
||||||
if (!schedulerFound)
|
|
||||||
|
if (!schedulerFound) {
|
||||||
dispatch(setScheduler(activeSchedulers[0].value as Scheduler));
|
dispatch(setScheduler(activeSchedulers[0].value as Scheduler));
|
||||||
|
}
|
||||||
}, [dispatch, selectedSchedulers, scheduler, activeSchedulers]);
|
}, [dispatch, selectedSchedulers, scheduler, activeSchedulers]);
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
|
@ -99,13 +99,20 @@ export const uiSlice = createSlice({
|
|||||||
setSelectedSchedulers: (state, action: PayloadAction<string[]>) => {
|
setSelectedSchedulers: (state, action: PayloadAction<string[]>) => {
|
||||||
const selectedSchedulerData: SelectItem[] = [];
|
const selectedSchedulerData: SelectItem[] = [];
|
||||||
|
|
||||||
if (action.payload.length === 0) action.payload = [SCHEDULERS[0].value];
|
let selectedSchedulers = [...action.payload];
|
||||||
|
|
||||||
action.payload.forEach((item) => {
|
if (selectedSchedulers.length === 0) {
|
||||||
|
selectedSchedulers = [SCHEDULERS[0].value];
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedSchedulers.forEach((item) => {
|
||||||
const schedulerData = SCHEDULERS.find(
|
const schedulerData = SCHEDULERS.find(
|
||||||
(scheduler) => scheduler.value === item
|
(scheduler) => scheduler.value === item
|
||||||
);
|
);
|
||||||
if (schedulerData) selectedSchedulerData.push(schedulerData);
|
|
||||||
|
if (schedulerData) {
|
||||||
|
selectedSchedulerData.push(schedulerData);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
state.activeSchedulers = selectedSchedulerData;
|
state.activeSchedulers = selectedSchedulerData;
|
||||||
|
Loading…
Reference in New Issue
Block a user