mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): layer counts
This commit is contained in:
parent
2062cfe84a
commit
fdfc379a84
@ -1,20 +1,43 @@
|
|||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { useAppSelector } from 'app/store/storeHooks';
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { isRegionalGuidanceLayer, selectControlLayersSlice } from 'features/controlLayers/store/controlLayersSlice';
|
import {
|
||||||
|
isControlAdapterLayer,
|
||||||
|
isInitialImageLayer,
|
||||||
|
isIPAdapterLayer,
|
||||||
|
isRegionalGuidanceLayer,
|
||||||
|
selectControlLayersSlice,
|
||||||
|
} from 'features/controlLayers/store/controlLayersSlice';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const selectValidLayerCount = createSelector(selectControlLayersSlice, (controlLayers) => {
|
const selectValidLayerCount = createSelector(selectControlLayersSlice, (controlLayers) => {
|
||||||
const validLayers = controlLayers.present.layers
|
let count = 0;
|
||||||
.filter(isRegionalGuidanceLayer)
|
controlLayers.present.layers.forEach((l) => {
|
||||||
.filter((l) => l.isEnabled)
|
if (isRegionalGuidanceLayer(l)) {
|
||||||
.filter((l) => {
|
|
||||||
const hasTextPrompt = Boolean(l.positivePrompt || l.negativePrompt);
|
const hasTextPrompt = Boolean(l.positivePrompt || l.negativePrompt);
|
||||||
const hasAtLeastOneImagePrompt = l.ipAdapters.length > 0;
|
const hasAtLeastOneImagePrompt = l.ipAdapters.filter((ipa) => Boolean(ipa.image)).length > 0;
|
||||||
return hasTextPrompt || hasAtLeastOneImagePrompt;
|
if (hasTextPrompt || hasAtLeastOneImagePrompt) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isControlAdapterLayer(l)) {
|
||||||
|
if (l.controlAdapter.image || l.controlAdapter.processedImage) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isIPAdapterLayer(l)) {
|
||||||
|
if (l.ipAdapter.image) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isInitialImageLayer(l)) {
|
||||||
|
if (l.image) {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return validLayers.length;
|
return count;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useControlLayersTitle = () => {
|
export const useControlLayersTitle = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user