Skip to content

Commit a4b9ae0

Browse files
authored
Merge pull request #229 from boostcampwm-2024/feature-historyState-fix
[Feature-history-state-fix] historyState 오류 해결
2 parents 5cc56bd + 3170b53 commit a4b9ae0

File tree

5 files changed

+5
-12
lines changed

5 files changed

+5
-12
lines changed

client/src/components/MindMapCanvas/ToolMenu.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export default function ToolMenu({ dimensions, zoomIn, zoomOut, dragmode, setDra
3333
};
3434

3535
function handleAddButton() {
36-
saveHistory(JSON.stringify(data));
3736
addNode(data, selectedNode, overrideNodeData, (newNodeId) => {
3837
selectNode({
3938
nodeId: newNodeId,
@@ -42,7 +41,6 @@ export default function ToolMenu({ dimensions, zoomIn, zoomOut, dragmode, setDra
4241
});
4342
}
4443
function handleDeleteButton() {
45-
saveHistory(JSON.stringify(data));
4644
deleteNodes(JSON.stringify(data), selectedNode.nodeId, overrideNodeData);
4745
selectNode({ nodeId: 0, parentNodeId: 0 });
4846
}

client/src/components/MindMapCanvas/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export default function MindMapCanvas({ showMinutes, handleShowMinutes }) {
2323
redoData: redo,
2424
updateNode,
2525
overrideNodeData,
26-
saveHistory,
2726
loadingStatus,
2827
deleteSelectedNodes,
2928
selectedNode,
@@ -44,7 +43,6 @@ export default function MindMapCanvas({ showMinutes, handleShowMinutes }) {
4443
payload: initializeNodePosition(data),
4544
callback: (response) => {
4645
if (response) {
47-
saveHistory(JSON.stringify(data));
4846
overrideNodeData(response);
4947
}
5048
},
@@ -54,7 +52,7 @@ export default function MindMapCanvas({ showMinutes, handleShowMinutes }) {
5452
useWindowEventListener("keydown", (e) => {
5553
e.preventDefault();
5654
if (e.metaKey || e.ctrlKey) {
57-
if (e.shiftKey && e.code) redo();
55+
if (e.shiftKey && e.code === "KeyZ") redo();
5856
switch (e.code) {
5957
case "KeyZ":
6058
undo();

client/src/components/MindMapMainSection/ControlSection/ListView/NodeItem.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function NodeItem({ node, parentNodeId, open, handleAccordion, op
3434
handleKeyDown,
3535
handleDelete,
3636
} = useNodeActions(node.id, node.keyword);
37-
const { data, saveHistory, selectedNode, overrideNodeData, selectNode } = useNodeListContext();
37+
const { data, selectedNode, overrideNodeData, selectNode } = useNodeListContext();
3838
const inputRef = useRef<HTMLInputElement | null>(null);
3939
const parentNodes = getParentNodeKeys(selectedNode.nodeId, data);
4040
const isSelected = parentNodes.includes(node.id);
@@ -48,7 +48,6 @@ export default function NodeItem({ node, parentNodeId, open, handleAccordion, op
4848
}, [isSelected]);
4949

5050
function handleAddButton() {
51-
saveHistory(JSON.stringify(data));
5251
selectNode({ nodeId: node.id, parentNodeId: parentNodeId });
5352
addNode(data, { nodeId: node.id, parentNodeId: parentNodeId }, overrideNodeData, (newNodeId) => {
5453
selectNode({ nodeId: newNodeId, parentNodeId: node.id });

client/src/hooks/useNodeActions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { addNode } from "@/konva_mindmap/events/addNode";
21
import { deleteNodes } from "@/konva_mindmap/events/deleteNode";
32
import { useNodeListContext } from "@/store/NodeListProvider";
43
import { useConnectionStore } from "@/store/useConnectionStore";
@@ -8,7 +7,7 @@ export default function useNodeActions(nodeId: number, content: string) {
87
const [hover, setHover] = useState<boolean>(false);
98
const [isEditing, setIsEditing] = useState<boolean>(false);
109
const [keyword, setKeyword] = useState(content);
11-
const { data, saveHistory, overrideNodeData } = useNodeListContext();
10+
const { data, overrideNodeData } = useNodeListContext();
1211
const handleSocketEvent = useConnectionStore((state) => state.handleSocketEvent);
1312
const currentJobStatus = useConnectionStore((state) => state.currentJobStatus);
1413

@@ -24,7 +23,6 @@ export default function useNodeActions(nodeId: number, content: string) {
2423
actionType: "updateNode",
2524
payload: { ...data, [nodeId]: { ...data[nodeId], keyword: keyword, newNode: false } },
2625
callback: (response) => {
27-
saveHistory(JSON.stringify(data));
2826
overrideNodeData(response);
2927
},
3028
});
@@ -62,7 +60,6 @@ export default function useNodeActions(nodeId: number, content: string) {
6260

6361
function handleDelete() {
6462
const stringifiedData = JSON.stringify(data);
65-
saveHistory(stringifiedData);
6663
deleteNodes(stringifiedData, nodeId, overrideNodeData);
6764
}
6865

client/src/store/NodeListProvider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function NodeListProvider({ children }: { children: ReactNode })
6060
updateLoadingStatus({ type: "socketLoading", status: true });
6161
setTimeout(() => {
6262
setData({ ...initialData.nodeData });
63-
overrideHistory(JSON.stringify(initialData));
63+
overrideHistory(JSON.stringify(initialData.nodeData));
6464
initializeTitle(initialData);
6565
initializeContent(initialData);
6666
initializeAiCount(initialData);
@@ -115,6 +115,7 @@ export default function NodeListProvider({ children }: { children: ReactNode })
115115

116116
function overrideNodeData(newData) {
117117
setData(newData);
118+
saveHistory(JSON.stringify(newData));
118119
}
119120

120121
function undoData() {

0 commit comments

Comments
 (0)