From 87d0335bfd3096a9be6feb95315e0d3a54afa8ac Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Thu, 4 Sep 2025 11:01:35 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EB=AA=A8=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EA=B3=A0=EC=B9=A8=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0:?= =?UTF-8?q?=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EC=8B=9C=20=EB=AA=A8=EB=93=A0?= =?UTF-8?q?=20=ED=95=A0=EC=9D=BC=20=EB=A9=94=EB=AA=A8=20=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/static/js/todos.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/frontend/static/js/todos.js b/frontend/static/js/todos.js index 8af43cb..fb8fc5f 100644 --- a/frontend/static/js/todos.js +++ b/frontend/static/js/todos.js @@ -102,6 +102,7 @@ function todosApp() { await this.loadTodos(); await this.loadStats(); + await this.loadAllTodoMemos(); // 주기적으로 활성 할일 업데이트 (1분마다) setInterval(() => { @@ -188,6 +189,11 @@ function todosApp() { }); this.todos.unshift(response); + + // 새 할일의 메모 상태 초기화 + this.todoMemos[response.id] = []; + this.showMemoForTodo[response.id] = false; + this.newTodoContent = ''; await this.loadStats(); @@ -505,6 +511,33 @@ function todosApp() { }); }, + // 모든 할일의 메모 로드 (초기화용) + async loadAllTodoMemos() { + try { + console.log('📋 모든 할일 메모 로드 중...'); + + // 모든 할일에 대해 메모 로드 + const memoPromises = this.todos.map(async (todo) => { + try { + const response = await window.api.get(`/todos/${todo.id}/comments`); + this.todoMemos[todo.id] = response || []; + if (this.todoMemos[todo.id].length > 0) { + console.log(`✅ ${todo.content.slice(0, 20)}... - ${this.todoMemos[todo.id].length}개 메모 로드`); + } + } catch (error) { + console.error(`❌ ${todo.id} 메모 로드 실패:`, error); + this.todoMemos[todo.id] = []; + } + }); + + await Promise.all(memoPromises); + console.log('✅ 모든 할일 메모 로드 완료'); + + } catch (error) { + console.error('❌ 전체 메모 로드 실패:', error); + } + }, + // 할일 메모 로드 (인라인용) async loadTodoMemos(todoId) { try {