mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-17 18:55:18 -05:00
There are a few breaking changes, which I've addressed. The vast majority of changes are related to new handling of `reselect`'s `createSelector` options. For better or worse, we memoize just about all our selectors using lodash `isEqual` for `resultEqualityCheck`. The upgrade requires we explicitly set the `memoize` option to `lruMemoize` to continue using lodash here. Doing that required changing our `defaultSelectorOptions`. Instead of changing that and finding dozens of instances where we weren't using that and instead were defining selector options manually, I've created a pre-configured selector: `createMemoizedSelector`. This is now used everywhere instead of `createSelector`.
25 lines
855 B
TypeScript
25 lines
855 B
TypeScript
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
|
import { stateSelector } from 'app/store/store';
|
|
import { useAppSelector } from 'app/store/storeHooks';
|
|
import { selectControlAdapterById } from 'features/controlAdapters/store/controlAdaptersSlice';
|
|
import { isControlNetOrT2IAdapter } from 'features/controlAdapters/store/types';
|
|
import { useMemo } from 'react';
|
|
|
|
export const useControlAdapterShouldAutoConfig = (id: string) => {
|
|
const selector = useMemo(
|
|
() =>
|
|
createMemoizedSelector(stateSelector, ({ controlAdapters }) => {
|
|
const ca = selectControlAdapterById(controlAdapters, id);
|
|
if (ca && isControlNetOrT2IAdapter(ca)) {
|
|
return ca.shouldAutoConfig;
|
|
}
|
|
return undefined;
|
|
}),
|
|
[id]
|
|
);
|
|
|
|
const controlMode = useAppSelector(selector);
|
|
|
|
return controlMode;
|
|
};
|