todo 오류 있던거 수정 이젠 디비꺼도 지워짐

This commit is contained in:
leeheejin 2025-10-20 18:04:49 +09:00
parent 86135dcf10
commit 1e3136cb0b
3 changed files with 29 additions and 51 deletions

View File

@ -1,54 +1,14 @@
[ [
{
"id": "e5bb334c-d58a-4068-ad77-2607a41f4675",
"title": "ㅁㄴㅇㄹ",
"description": "ㅁㄴㅇㄹ",
"priority": "normal",
"status": "completed",
"assignedTo": "",
"dueDate": "2025-10-20T18:17",
"createdAt": "2025-10-20T06:15:49.610Z",
"updatedAt": "2025-10-20T07:36:06.370Z",
"isUrgent": false,
"order": 0,
"completedAt": "2025-10-20T07:36:06.370Z"
},
{
"id": "334be17c-7776-47e8-89ec-4b57c4a34bcd",
"title": "연동되어주겠니?",
"description": "",
"priority": "normal",
"status": "pending",
"assignedTo": "",
"dueDate": "",
"createdAt": "2025-10-20T06:20:06.343Z",
"updatedAt": "2025-10-20T06:20:06.343Z",
"isUrgent": false,
"order": 1
},
{
"id": "f85b81de-fcbd-4858-8973-247d9d6e70ed",
"title": "연동되어주겠니?11",
"description": "ㄴㅇㄹ",
"priority": "normal",
"status": "pending",
"assignedTo": "",
"dueDate": "2025-10-20T17:22",
"createdAt": "2025-10-20T06:20:53.818Z",
"updatedAt": "2025-10-20T06:20:53.818Z",
"isUrgent": false,
"order": 2
},
{ {
"id": "58d2b26f-5197-4df1-b5d4-724a72ee1d05", "id": "58d2b26f-5197-4df1-b5d4-724a72ee1d05",
"title": "연동되어주려무니", "title": "연동되어주려무니",
"description": "ㅁㄴㅇㄹ", "description": "ㅁㄴㅇㄹ",
"priority": "normal", "priority": "normal",
"status": "pending", "status": "in_progress",
"assignedTo": "", "assignedTo": "",
"dueDate": "2025-10-21T15:21", "dueDate": "2025-10-21T15:21",
"createdAt": "2025-10-20T06:21:19.817Z", "createdAt": "2025-10-20T06:21:19.817Z",
"updatedAt": "2025-10-20T06:21:19.817Z", "updatedAt": "2025-10-20T09:00:26.948Z",
"isUrgent": false, "isUrgent": false,
"order": 3 "order": 3
} }

View File

@ -155,10 +155,15 @@ export class TodoService {
updates: Partial<TodoItem> updates: Partial<TodoItem>
): Promise<TodoItem> { ): Promise<TodoItem> {
try { try {
if (DATA_SOURCE === "database") { // 먼저 데이터베이스에서 찾아보고, 없으면 파일에서 찾기
try {
return await this.updateTodoDB(id, updates); return await this.updateTodoDB(id, updates);
} else { } catch (dbError: any) {
return this.updateTodoFile(id, updates); // 데이터베이스에서 찾지 못했으면 파일에서 찾기
if (dbError.message && dbError.message.includes("찾을 수 없습니다")) {
return this.updateTodoFile(id, updates);
}
throw dbError;
} }
} catch (error) { } catch (error) {
logger.error("❌ To-Do 수정 오류:", error); logger.error("❌ To-Do 수정 오류:", error);
@ -171,10 +176,16 @@ export class TodoService {
*/ */
public async deleteTodo(id: string): Promise<void> { public async deleteTodo(id: string): Promise<void> {
try { try {
if (DATA_SOURCE === "database") { // 먼저 데이터베이스에서 찾아보고, 없으면 파일에서 찾기
try {
await this.deleteTodoDB(id); await this.deleteTodoDB(id);
} else { } catch (dbError: any) {
this.deleteTodoFile(id); // 데이터베이스에서 찾지 못했으면 파일에서 찾기
if (dbError.message && dbError.message.includes("찾을 수 없습니다")) {
this.deleteTodoFile(id);
} else {
throw dbError;
}
} }
logger.info(`✅ To-Do 삭제: ${id}`); logger.info(`✅ To-Do 삭제: ${id}`);
} catch (error) { } catch (error) {

View File

@ -249,11 +249,18 @@ export default function TodoWidget({ element }: TodoWidgetProps) {
}, },
}); });
if (response.ok) { // 응답이 성공이거나, 500 에러여도 실제로는 삭제되었을 수 있으므로 목록 새로고침
fetchTodos(); if (response.ok || response.status === 500) {
// 약간의 딜레이 후 새로고침 (백엔드 처리 완료 대기)
setTimeout(() => {
fetchTodos();
}, 300);
} }
} catch (error) { } catch (error) {
// console.error("To-Do 삭제 오류:", error); // 네트워크 에러여도 삭제되었을 수 있으므로 새로고침
setTimeout(() => {
fetchTodos();
}, 300);
} }
}; };