Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace RF component selector with new type #2491

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/common-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export type OfKind<T extends { readonly kind: string }, Kind extends T['kind']>
: never;

export type NodeKind = 'regularNode' | 'newIterator' | 'collector';
export type NodeType = 'backendNode';

export type InputData = Readonly<Record<InputId, InputValue>>;
export type InputHeight = Readonly<Record<InputId, number>>;
Expand Down
8 changes: 8 additions & 0 deletions src/common/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,13 @@ const saveVideoInputPR2514: ModernMigration = (data) => {
return data;
};

const updateNodeTypesToKinds: ModernMigration = (data) => {
data.nodes.forEach((node) => {
node.type = 'backendNode';
});
return data;
};

// ==============

const versionToMigration = (version: string) => {
Expand Down Expand Up @@ -1978,6 +1985,7 @@ const migrations = [
createBorderEdgesTileFillToPad,
unifiedResizeNode,
saveVideoInputPR2514,
updateNodeTypesToKinds,
];

export const currentMigration = migrations.length;
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/helpers/reactFlowUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ export const createNode = (
schemata: SchemaMap,
selected = false
): Node<NodeData> => {
const schema = schemata.get(data.schemaId);

const newNode: Node<Mutable<NodeData>> = {
type: schema.kind,
type: 'backendNode',
id,
position: { ...position },
data: {
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { memo, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { EdgeTypes, NodeTypes, ReactFlowProvider } from 'reactflow';
import { useContext } from 'use-context-selector';
import { NodeKind } from '../common/common-types';
import { NodeType } from '../common/common-types';
import { getLocalStorage, getStorageKeys } from '../common/util';
import { ChaiNNerLogo } from './components/chaiNNerLogo';
import { CustomEdge } from './components/CustomEdge/CustomEdge';
Expand All @@ -22,10 +22,8 @@ import { SettingsProvider } from './contexts/SettingsContext';
import { useIpcRendererListener } from './hooks/useIpcRendererListener';
import { useLastWindowSize } from './hooks/useLastWindowSize';

const nodeTypes: NodeTypes & Record<NodeKind, unknown> = {
regularNode: Node,
newIterator: Node,
collector: Node,
const nodeTypes: NodeTypes & Record<NodeType, unknown> = {
backendNode: Node,
};
const edgeTypes: EdgeTypes = {
main: CustomEdge,
Expand Down
Loading
Loading