mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): remove selectionDeleted action
This commit is contained in:
parent
7cceafe0dd
commit
b8b671c0db
@ -17,7 +17,6 @@ import {
|
|||||||
edgesChanged,
|
edgesChanged,
|
||||||
nodesChanged,
|
nodesChanged,
|
||||||
redo,
|
redo,
|
||||||
selectionDeleted,
|
|
||||||
undo,
|
undo,
|
||||||
} from 'features/nodes/store/nodesSlice';
|
} from 'features/nodes/store/nodesSlice';
|
||||||
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
||||||
@ -263,8 +262,22 @@ export const Flow = memo(() => {
|
|||||||
useHotkeys('esc', onEscapeHotkey);
|
useHotkeys('esc', onEscapeHotkey);
|
||||||
|
|
||||||
const onDeleteHotkey = useCallback(() => {
|
const onDeleteHotkey = useCallback(() => {
|
||||||
dispatch(selectionDeleted());
|
const { nodes, edges } = store.getState().nodes.present;
|
||||||
}, [dispatch]);
|
const nodeChanges: NodeChange[] = [];
|
||||||
|
const edgeChanges: EdgeChange[] = [];
|
||||||
|
nodes
|
||||||
|
.filter((n) => n.selected)
|
||||||
|
.forEach(({ id }) => {
|
||||||
|
nodeChanges.push({ type: 'remove', id });
|
||||||
|
});
|
||||||
|
edges
|
||||||
|
.filter((e) => e.selected)
|
||||||
|
.forEach(({ id }) => {
|
||||||
|
edgeChanges.push({ type: 'remove', id });
|
||||||
|
});
|
||||||
|
dispatch(nodesChanged(nodeChanges));
|
||||||
|
dispatch(edgesChanged(edgeChanges));
|
||||||
|
}, [dispatch, store]);
|
||||||
useHotkeys(['delete', 'backspace'], onDeleteHotkey);
|
useHotkeys(['delete', 'backspace'], onDeleteHotkey);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -347,23 +347,6 @@ export const nodesSlice = createSlice({
|
|||||||
state.nodes = [];
|
state.nodes = [];
|
||||||
state.edges = [];
|
state.edges = [];
|
||||||
},
|
},
|
||||||
selectionDeleted: (state) => {
|
|
||||||
const selectedNodes = state.nodes.filter((n) => n.selected);
|
|
||||||
const selectedEdges = state.edges.filter((e) => e.selected);
|
|
||||||
|
|
||||||
const nodeChanges: NodeChange[] = selectedNodes.map((n) => ({
|
|
||||||
id: n.id,
|
|
||||||
type: 'remove',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const edgeChanges: EdgeChange[] = selectedEdges.map((e) => ({
|
|
||||||
id: e.id,
|
|
||||||
type: 'remove',
|
|
||||||
}));
|
|
||||||
|
|
||||||
state.nodes = applyNodeChanges(nodeChanges, state.nodes);
|
|
||||||
state.edges = applyEdgeChanges(edgeChanges, state.edges);
|
|
||||||
},
|
|
||||||
undo: (state) => state,
|
undo: (state) => state,
|
||||||
redo: (state) => state,
|
redo: (state) => state,
|
||||||
},
|
},
|
||||||
@ -414,7 +397,6 @@ export const {
|
|||||||
nodesChanged,
|
nodesChanged,
|
||||||
nodeUseCacheChanged,
|
nodeUseCacheChanged,
|
||||||
notesNodeValueChanged,
|
notesNodeValueChanged,
|
||||||
selectionDeleted,
|
|
||||||
undo,
|
undo,
|
||||||
redo,
|
redo,
|
||||||
} = nodesSlice.actions;
|
} = nodesSlice.actions;
|
||||||
@ -530,6 +512,5 @@ export const isAnyNodeOrEdgeMutation = isAnyOf(
|
|||||||
nodeLabelChanged,
|
nodeLabelChanged,
|
||||||
nodeNotesChanged,
|
nodeNotesChanged,
|
||||||
nodeUseCacheChanged,
|
nodeUseCacheChanged,
|
||||||
notesNodeValueChanged,
|
notesNodeValueChanged
|
||||||
selectionDeleted
|
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user