fix: 하이라이트/메모 API 오류 및 플로팅 메모창 문제 해결

🐛 버그 수정:
- InstrumentedList 오류 해결: highlight.notes 리스트 접근 방식 수정
- this.filterMemos 함수 스코프 오류 해결: this 컨텍스트 안전 처리
- 하이라이트 API에서 메모 관계 로딩 추가 (selectinload)
- 플로팅 메모창 showFloatingMemo 변수 인식 문제 해결

🛠️ 개선사항:
- 안전한 함수 호출: typeof 체크 및 대체 로직 추가
- 하이라이트 응답에 연관된 메모 데이터 포함
- 캐시 버스팅 버전 업데이트 (v2025012227)
- 디버깅 로그 추가로 문제 진단 개선

 결과:
- 하이라이트와 메모가 정상적으로 표시됨
- 플로팅 메모창이 올바르게 작동함
- API 500 오류 해결로 데이터 안전성 확보
This commit is contained in:
Hyungi Ahn
2025-08-25 07:27:24 +09:00
parent c7f55ac50d
commit 5bfa3822ca
3 changed files with 42 additions and 13 deletions

View File

@@ -173,9 +173,10 @@ async def get_document_highlights(
detail="Not enough permissions to access this document"
)
# 사용자의 하이라이트만 조회
# 사용자의 하이라이트만 조회 (연관된 메모도 함께 로드)
result = await db.execute(
select(Highlight)
.options(selectinload(Highlight.notes)) # 메모 관계 로드
.where(
and_(
Highlight.document_id == document_id,
@@ -191,6 +192,17 @@ async def get_document_highlights(
# 응답 데이터 변환
response_data = []
for highlight in highlights:
# 연관된 메모 정보 포함 (notes는 리스트이므로 첫 번째 메모 사용)
note_data = None
if highlight.notes and len(highlight.notes) > 0:
first_note = highlight.notes[0] # 첫 번째 메모 사용
note_data = {
"id": str(first_note.id),
"content": first_note.content,
"created_at": first_note.created_at.isoformat(),
"updated_at": first_note.updated_at.isoformat() if first_note.updated_at else None
}
highlight_data = HighlightResponse(
id=str(highlight.id),
user_id=str(highlight.user_id),
@@ -205,7 +217,7 @@ async def get_document_highlights(
highlight_type=highlight.highlight_type,
created_at=highlight.created_at,
updated_at=highlight.updated_at,
note=None
note=note_data
)
response_data.append(highlight_data)