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,
|
||||
nodesChanged,
|
||||
redo,
|
||||
selectionDeleted,
|
||||
undo,
|
||||
} from 'features/nodes/store/nodesSlice';
|
||||
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
||||
@ -263,8 +262,22 @@ export const Flow = memo(() => {
|
||||
useHotkeys('esc', onEscapeHotkey);
|
||||
|
||||
const onDeleteHotkey = useCallback(() => {
|
||||
dispatch(selectionDeleted());
|
||||
}, [dispatch]);
|
||||
const { nodes, edges } = store.getState().nodes.present;
|
||||
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);
|
||||
|
||||
return (
|
||||
|
@ -347,23 +347,6 @@ export const nodesSlice = createSlice({
|
||||
state.nodes = [];
|
||||
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,
|
||||
redo: (state) => state,
|
||||
},
|
||||
@ -414,7 +397,6 @@ export const {
|
||||
nodesChanged,
|
||||
nodeUseCacheChanged,
|
||||
notesNodeValueChanged,
|
||||
selectionDeleted,
|
||||
undo,
|
||||
redo,
|
||||
} = nodesSlice.actions;
|
||||
@ -530,6 +512,5 @@ export const isAnyNodeOrEdgeMutation = isAnyOf(
|
||||
nodeLabelChanged,
|
||||
nodeNotesChanged,
|
||||
nodeUseCacheChanged,
|
||||
notesNodeValueChanged,
|
||||
selectionDeleted
|
||||
notesNodeValueChanged
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user