mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Add activeModelSelector
Active Model details are used in multiple places. So makes sense to have a selector for it.
This commit is contained in:
parent
d5810f6270
commit
a7dd7b4298
@ -1,6 +1,31 @@
|
|||||||
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { RootState } from 'app/store';
|
import { RootState } from 'app/store';
|
||||||
import { SystemState } from './systemSlice';
|
import { SystemState } from './systemSlice';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const systemSelector = (state: RootState): SystemState => state.system;
|
export const systemSelector = (state: RootState): SystemState => state.system;
|
||||||
|
|
||||||
export const toastQueueSelector = (state: RootState) => state.system.toastQueue;
|
export const toastQueueSelector = (state: RootState) => state.system.toastQueue;
|
||||||
|
|
||||||
|
export const activeModelSelector = createSelector(
|
||||||
|
systemSelector,
|
||||||
|
(system) => {
|
||||||
|
const { model_list } = system;
|
||||||
|
const activeModel = _.reduce(
|
||||||
|
model_list,
|
||||||
|
(acc, model, key) => {
|
||||||
|
if (model.status === 'active') {
|
||||||
|
acc = key;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
''
|
||||||
|
);
|
||||||
|
return { ...model_list[activeModel], name: activeModel };
|
||||||
|
},
|
||||||
|
{
|
||||||
|
memoizeOptions: {
|
||||||
|
resultEqualityCheck: _.isEqual,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user