mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
chore(ui): clean up modelSlice
This commit is contained in:
parent
84b801d88f
commit
9f4d39aa42
@ -13,26 +13,15 @@ export const modelsAdapter = createEntityAdapter<Model>({
|
||||
sortComparer: (a, b) => a.name.localeCompare(b.name),
|
||||
});
|
||||
|
||||
type AdditionalModelsState = {
|
||||
selectedModelName: string;
|
||||
};
|
||||
|
||||
export const initialModelsState =
|
||||
modelsAdapter.getInitialState<AdditionalModelsState>({
|
||||
selectedModelName: '',
|
||||
});
|
||||
export const initialModelsState = modelsAdapter.getInitialState();
|
||||
|
||||
export type ModelsState = typeof initialModelsState;
|
||||
|
||||
export const modelsSlice = createSlice({
|
||||
name: 'models',
|
||||
initialState: modelsAdapter.getInitialState(),
|
||||
// initialState: initialModelsState,
|
||||
initialState: initialModelsState,
|
||||
reducers: {
|
||||
modelAdded: modelsAdapter.upsertOne,
|
||||
// modelSelected: (state, action: PayloadAction<string>) => {
|
||||
// state.selectedModelName = action.payload;
|
||||
// },
|
||||
},
|
||||
extraReducers(builder) {
|
||||
/**
|
||||
@ -41,32 +30,10 @@ export const modelsSlice = createSlice({
|
||||
builder.addCase(receivedModels.fulfilled, (state, action) => {
|
||||
const models = action.payload;
|
||||
modelsAdapter.setAll(state, models);
|
||||
|
||||
// If the current selected model is `''` or isn't actually in the list of models,
|
||||
// choose a random model
|
||||
// if (
|
||||
// !state.selectedModelName ||
|
||||
// !keys(models).includes(state.selectedModelName)
|
||||
// ) {
|
||||
// const randomModel = sample(models);
|
||||
|
||||
// if (randomModel) {
|
||||
// state.selectedModelName = randomModel.name;
|
||||
// } else {
|
||||
// state.selectedModelName = '';
|
||||
// }
|
||||
// }
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// export const selectedModelSelector = (state: RootState) => {
|
||||
// const { selectedModelName } = state.models;
|
||||
// const selectedModel = selectModelsById(state, selectedModelName);
|
||||
|
||||
// return selectedModel ?? null;
|
||||
// };
|
||||
|
||||
export const {
|
||||
selectAll: selectModelsAll,
|
||||
selectById: selectModelsById,
|
||||
@ -75,9 +42,6 @@ export const {
|
||||
selectTotal: selectModelsTotal,
|
||||
} = modelsAdapter.getSelectors<RootState>((state) => state.models);
|
||||
|
||||
export const {
|
||||
modelAdded,
|
||||
// modelSelected
|
||||
} = modelsSlice.actions;
|
||||
export const { modelAdded } = modelsSlice.actions;
|
||||
|
||||
export default modelsSlice.reducer;
|
||||
|
Loading…
Reference in New Issue
Block a user