mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
chore(ui): lint
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
useConnectionValidationResult,
|
||||
useIsConnectionInProgress,
|
||||
useIsConnectionStartField,
|
||||
} from 'features/nodes/hooks/useInputFieldConnectionState';
|
||||
} from 'features/nodes/hooks/useFieldConnectionState';
|
||||
import { useInputFieldTemplate } from 'features/nodes/hooks/useInputFieldTemplate';
|
||||
import { useFieldTypeName } from 'features/nodes/hooks/usePrettyFieldType';
|
||||
import { HANDLE_TOOLTIP_OPEN_DELAY, MODEL_TYPES } from 'features/nodes/types/constants';
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
useConnectionValidationResult,
|
||||
useIsConnectionInProgress,
|
||||
useIsConnectionStartField,
|
||||
} from 'features/nodes/hooks/useInputFieldConnectionState';
|
||||
} from 'features/nodes/hooks/useFieldConnectionState';
|
||||
import { useInputFieldIsConnected } from 'features/nodes/hooks/useInputFieldIsConnected';
|
||||
import { useInputFieldLabel } from 'features/nodes/hooks/useInputFieldLabel';
|
||||
import { useInputFieldTemplateTitle } from 'features/nodes/hooks/useInputFieldTemplateTitle';
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
useConnectionValidationResult,
|
||||
useIsConnectionInProgress,
|
||||
useIsConnectionStartField,
|
||||
} from 'features/nodes/hooks/useInputFieldConnectionState';
|
||||
} from 'features/nodes/hooks/useFieldConnectionState';
|
||||
import { useOutputFieldTemplate } from 'features/nodes/hooks/useOutputFieldTemplate';
|
||||
import { useFieldTypeName } from 'features/nodes/hooks/usePrettyFieldType';
|
||||
import { HANDLE_TOOLTIP_OPEN_DELAY, MODEL_TYPES } from 'features/nodes/types/constants';
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
useConnectionValidationResult,
|
||||
useIsConnectionInProgress,
|
||||
useIsConnectionStartField,
|
||||
} from 'features/nodes/hooks/useInputFieldConnectionState';
|
||||
} from 'features/nodes/hooks/useFieldConnectionState';
|
||||
import { useInputFieldIsConnected } from 'features/nodes/hooks/useInputFieldIsConnected';
|
||||
import { useOutputFieldTemplate } from 'features/nodes/hooks/useOutputFieldTemplate';
|
||||
import { HANDLE_TOOLTIP_OPEN_DELAY } from 'features/nodes/types/constants';
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import { $edgePendingUpdate, $pendingConnection, $templates } from 'features/nodes/store/nodesSlice';
|
||||
import { makeConnectionErrorSelector } from 'features/nodes/store/util/makeConnectionErrorSelector';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const useOutputFieldConnectionState = (nodeId: string, fieldName: string) => {
|
||||
const pendingConnection = useStore($pendingConnection);
|
||||
const templates = useStore($templates);
|
||||
const edgePendingUpdate = useStore($edgePendingUpdate);
|
||||
|
||||
const selectValidationResult = useMemo(
|
||||
() => makeConnectionErrorSelector(templates, nodeId, fieldName, 'source', pendingConnection, edgePendingUpdate),
|
||||
[templates, nodeId, fieldName, pendingConnection, edgePendingUpdate]
|
||||
);
|
||||
|
||||
const isConnectionInProgress = useMemo(() => Boolean(pendingConnection), [pendingConnection]);
|
||||
const isConnectionStartField = useMemo(() => {
|
||||
if (!pendingConnection) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
pendingConnection.nodeId === nodeId &&
|
||||
pendingConnection.handleId === fieldName &&
|
||||
pendingConnection.fieldTemplate.fieldKind === 'output'
|
||||
);
|
||||
}, [fieldName, nodeId, pendingConnection]);
|
||||
const validationResult = useAppSelector(selectValidationResult);
|
||||
|
||||
return {
|
||||
isConnectionInProgress,
|
||||
isConnectionStartField,
|
||||
validationResult,
|
||||
};
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { useAppSelector } from 'app/store/storeHooks';
|
||||
import { selectNodesSlice } from 'features/nodes/store/selectors';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const useOutputFieldIsConnected = (nodeId: string, fieldName: string) => {
|
||||
const selector = useMemo(
|
||||
() =>
|
||||
createSelector(selectNodesSlice, (nodes) => {
|
||||
const firstConnectedEdge = nodes.edges.find((edge) => {
|
||||
return edge.source === nodeId && edge.sourceHandle === fieldName;
|
||||
});
|
||||
return firstConnectedEdge !== undefined;
|
||||
}),
|
||||
[fieldName, nodeId]
|
||||
);
|
||||
|
||||
const isConnected = useAppSelector(selector);
|
||||
|
||||
return isConnected;
|
||||
};
|
||||
@@ -9,7 +9,7 @@ import type { SetNonNullable } from 'type-fest';
|
||||
|
||||
type Connection = SetNonNullable<NullableConnection>;
|
||||
|
||||
export type ValidationResult =
|
||||
type ValidationResult =
|
||||
| {
|
||||
isValid: true;
|
||||
messageTKey?: string;
|
||||
|
||||
Reference in New Issue
Block a user