Skip to content

[#602] 앱이 독에 내려갔을 때 Todo Fetch 요청이 되는 현상을 해결한다#657

Merged
opficdev merged 12 commits into
developfrom
refactor/#602-anonymous-background-widget-fetch
Jun 30, 2026
Merged

[#602] 앱이 독에 내려갔을 때 Todo Fetch 요청이 되는 현상을 해결한다#657
opficdev merged 12 commits into
developfrom
refactor/#602-anonymous-background-widget-fetch

Conversation

@opficdev

@opficdev opficdev commented Jun 28, 2026

Copy link
Copy Markdown
Owner

🔗 연관된 이슈

🎯 의도

  • 앱이 백그라운드로 전환될 때 위젯 갱신을 위해 불필요한 Todo fetch가 반복되는 문제 완화
  • 위젯 스냅샷을 앱 내부 변경 흐름에서 재생성하도록 구성해 네트워크 요청 범위 축소

📝 작업 내용

📌 요약

  • 로그인 세션 복구 시점에만 위젯 원본 데이터를 최초 fetch하도록 위젯 동기화 흐름 정리
  • 앱 실행 중 날짜가 변경된 뒤 백그라운드로 전환되는 경우에만 날짜 기준 위젯 동기화 허용
  • Todo 추가, 수정, 삭제, 복구 후 네트워크 fetch 없이 메모리 원본과 위젯 스냅샷을 갱신하도록 구성
  • 위젯 설정 변경 시 네트워크 fetch 없이 저장된 원본으로 Today, Heatmap 스냅샷을 재생성하도록 구성
  • Today 위젯 스냅샷 저장 항목을 실제 표시 가능한 최대 3개로 제한
  • TodayWidgetSectionSnapshot 제거 및 WidgetTodayTodoSnapshot 기반 item 저장 구조로 정리

🔍 상세

  • WidgetSessionSyncHandler에서 로그인 세션이 활성화될 때 .syncRequested를 발행해 Today, Heatmap 원본 데이터를 최초 구성
  • DevLogAppscenePhase == .background 처리에서 같은 날 반복 동기화를 막고, 날짜가 변경된 경우에만 .syncRequested 발행
  • WidgetSyncEventHandler.refreshRequested 처리에서 기존 원본을 사용해 Today, Heatmap 스냅샷만 재생성
  • TodoRepositoryImpl의 Todo 추가, 수정, 삭제, 복구 성공 후 WidgetSnapshotUpdater를 통해 위젯 원본과 스냅샷 갱신
  • UserPreferencesRepositoryImpl의 Today 표시 옵션 및 Heatmap 활동 설정 변경 후 .refreshRequested 발행
  • WidgetSnapshotUpdaterImpl에서 Today, Heatmap 원본을 메모리에 유지하고 설정 변경이나 Todo 변경 시 저장된 원본 기준으로 스냅샷 재생성
  • TodayWidgetSnapshotFactory에서 Today 표시 순서 기준 최대 3개 항목만 snapshot item으로 저장
  • WidgetTodoSnapshotItem 대신 WidgetHeatmapDaySnapshot과 이름 결이 맞는 WidgetTodayTodoSnapshot 사용

작업 노트

  • 설정된 위젯 종류 조회 기반 분기는 위젯 제거 직후 WidgetCenter의 현재 설정 정보가 즉시 반영되지 않는 케이스가 있어 제거
  • 날짜 기반 안전장치는 Today 위젯의 지연, 임박, 나중 일정 분류가 현재 날짜에 의존하기 때문에 유지
  • 콘텐츠 추가, 수정, 삭제 기반 안전장치는 별도 네트워크 fetch 트리거가 아니라 앱 내부 Todo 변경 성공 후 저장된 위젯 원본과 snapshot을 직접 갱신하는 형태로 구성
  • Heatmap 설정 변경은 서버 데이터 변경이 아니라 표시 옵션 변경이므로 저장된 원본으로 snapshot만 재생성하는 흐름으로 구성
  • Today snapshot은 UI에서 최대 3개만 표시하므로 UserDefaults에 저장되는 항목도 최대 3개로 제한
  • 로그인 세션 기반 최초 fetch는 앱 재시작 후 메모리 원본을 다시 채우기 위한 초기화 흐름으로 유지

📸 영상 / 이미지 (Optional)

@opficdev opficdev self-assigned this Jun 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 풀 리퀘스트는 활성화된 위젯 종류에 따라 필요한 스냅샷만 선택적으로 갱신하도록 개선하고, 앱이 백그라운드로 진입할 때 날짜 변경 여부 및 동기화 요청 상태를 확인하여 효율적으로 동기화를 수행하도록 수정합니다. 이에 대해 WidgetSyncEventBusImpl에서 스레드 안전성을 확보하고 데드락을 방지하기 위해 NSRecursiveLock을 도입하고 publish(_:) 메서드를 보호할 것을 제안했습니다. 또한, confirmRequest() 메서드에 @discardableResult 속성을 추가하여 불필요한 _ = 대입 식을 제거하고 코드를 더 깔끔하게 개선할 것을 권장했습니다.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread Application/DevLogWidget/Sources/Widget/WidgetSyncEventBusImpl.swift Outdated
Comment thread Application/DevLogData/Sources/Widget/WidgetSyncEventBus.swift Outdated
Comment thread Application/DevLogWidget/Sources/Widget/WidgetSyncEventBusImpl.swift Outdated
Comment thread Application/DevLogApp/Sources/App/DevLogApp.swift Outdated
@opficdev opficdev closed this Jun 28, 2026
@opficdev opficdev reopened this Jun 30, 2026
@opficdev

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 풀 리퀘스트는 위젯 동기화 방식을 매번 네트워크에서 전체 데이터를 가져오는 방식에서 로컬 스냅샷을 증분 업데이트하는 방식으로 개선하고, Today 위젯 스냅샷 구조를 단순화하는 변경을 포함하고 있습니다. 리뷰 결과, 1) deleteTodoSnapshot에서 todayTodos를 먼저 삭제하여 힙맵에 삭제 활동이 누락되는 버그, 2) TodoDraft 생성 시 numbernil이라 위젯에서 누락되는 문제, 3) restoreTodoSnapshot에서 sourceTodo(id:) 중복 호출을 줄이는 최적화 방안이 제시되었습니다.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread Application/DevLogData/Sources/Repository/TodoRepositoryImpl.swift
@opficdev opficdev merged commit 1ad4597 into develop Jun 30, 2026
6 checks passed
@opficdev opficdev deleted the refactor/#602-anonymous-background-widget-fetch branch June 30, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

앱이 독에 내려갔을 때 Todo Fetch 요청이 되는 현상을 해결한다

1 participant