Skip to content

Commit

Permalink
fix: edit 시 입력받은 inputTodo로만 update되는 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
kumsil1006 committed Dec 1, 2022
1 parent 6e968fc commit d9251d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/src/core/todo/todoList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class TodoList {
async edit(id: string, todo: InputTodo): Promise<TodoList> {
const oldTodo = this.todoList.find((el) => el.id === id);
if (oldTodo === undefined) throw new Error('ERROR: 수정하려는 ID의 Todo가 존재하지 않습니다.');
const newTodo = new Todo({ ...todo, id: oldTodo.id });
const newTodo = new Todo({ ...oldTodo.toPlain(), ...todo, id: oldTodo.id });
const changedTodoSet = new Set<Todo>();

[this.getPrev(oldTodo), this.getPrev(newTodo), this.getNext(oldTodo), this.getNext(newTodo), newTodo]
Expand Down
17 changes: 1 addition & 16 deletions client/src/hooks/useTodoList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAtom } from 'jotai';
import { todoList, postponeClicked, isOnProgress, elasedTimeAtom } from '@util/GlobalState.js';
import { todoList, postponeClicked, isOnProgress } from '@util/GlobalState.js';
import useElapsedTime from './useElapsedTime.js';
import useActiveTodo from './useActiveTodo.js';
import usePostpone from './usePostpone';
Expand All @@ -15,20 +15,6 @@ const useTodoList = (): any => {
const [setDone] = useDone(activeTodo, setActiveTodo, elapsedTime, setElapsedTime);
const [userState] = useAtom(isOnProgress);
const [buttonConfig, handleOnToggle] = useButtonConfig(userState, startTimer, stopTimer);
// const [time] = useAtom(elasedTimeAtom);

// const beforeMovePage = (): void => {
// stopTimer();
// handleOnToggle();
// todoListAtom
// .updateElapsedTime(time)
// .then((newTodoList) => {
// setTodoListAtom(newTodoList);
// })
// .catch((err) => {
// throw new Error(err.message);
// });
// };

return {
setPostpone,
Expand All @@ -41,7 +27,6 @@ const useTodoList = (): any => {
displayTime,
buttonConfig,
handleOnToggle,
beforeMovePage,
stopTimer,
};
};
Expand Down

0 comments on commit d9251d4

Please sign in to comment.