feat(ui): enabledSchedulers -> favoriteSchedulers

This commit is contained in:
psychedelicious
2023-06-18 20:01:05 +10:00
parent 450641c414
commit b96b95bc95
7 changed files with 45 additions and 79 deletions

View File

@ -1,5 +1,5 @@
import { createSelector } from '@reduxjs/toolkit';
import { SCHEDULER_SELECT_ITEMS } from 'app/constants';
import { SCHEDULER_LABEL_MAP, SCHEDULER_NAMES } from 'app/constants';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
import IAIMantineSelect from 'common/components/IAIMantineSelect';
@ -14,14 +14,15 @@ const selector = createSelector(
[uiSelector, generationSelector],
(ui, generation) => {
const { scheduler } = generation;
const { enabledSchedulers } = ui;
const { favoriteSchedulers: enabledSchedulers } = ui;
const data = enabledSchedulers
.map(
(schedulerName) =>
SCHEDULER_SELECT_ITEMS[schedulerName as SchedulerParam]
)
.sort((a, b) => a.label.localeCompare(b.label));
const data = SCHEDULER_NAMES.map((schedulerName) => ({
value: schedulerName,
label: SCHEDULER_LABEL_MAP[schedulerName as SchedulerParam],
group: enabledSchedulers.includes(schedulerName)
? 'Favorites'
: undefined,
})).sort((a, b) => a.label.localeCompare(b.label));
return {
scheduler,

View File

@ -17,7 +17,6 @@ import {
StrengthParam,
WidthParam,
} from './parameterZodSchemas';
import { enabledSchedulersChanged } from 'features/ui/store/uiSlice';
import { DEFAULT_SCHEDULER_NAME } from 'app/constants';
export interface GenerationState {
@ -242,21 +241,6 @@ export const generationSlice = createSlice({
state.initialImage.thumbnail_url = thumbnail_url;
}
});
builder.addCase(enabledSchedulersChanged, (state, action) => {
const enabledSchedulers = action.payload;
if (!action.payload.length) {
// This means the user cleared the enabled schedulers multi-select. We need to set the scheduler to the default
state.scheduler = DEFAULT_SCHEDULER_NAME;
return;
}
if (!enabledSchedulers.includes(state.scheduler)) {
// The current scheduler is now disabled, change it to the first enabled one
state.scheduler = action.payload[0];
}
});
},
});