fix(ui): set default model to first model (alpha sort)

This commit is contained in:
psychedelicious 2023-05-30 22:01:21 +10:00 committed by Kent Keirsey
parent a9a2bd90c2
commit 9687fe7bac

View File

@ -2,7 +2,7 @@ import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';
import * as InvokeAI from 'app/types/invokeai';
import promptToString from 'common/util/promptToString';
import { clamp, sample } from 'lodash-es';
import { clamp, sample, sortBy } from 'lodash-es';
import { setAllParametersReducer } from './setAllParametersReducer';
import { receivedModels } from 'services/thunks/model';
import { Scheduler } from 'app/constants';
@ -227,10 +227,8 @@ export const generationSlice = createSlice({
extraReducers: (builder) => {
builder.addCase(receivedModels.fulfilled, (state, action) => {
if (!state.model) {
const randomModel = sample(action.payload);
if (randomModel) {
state.model = randomModel.name;
}
const firstModel = sortBy(action.payload, 'name')[0];
state.model = firstModel.name;
}
});
},