Skip to content

[#532] Todo 카테고리가 무지성 fetch되는 현상을 해결한다#562

Merged
opficdev merged 19 commits into
developfrom
fix/#532-fetch
Jun 9, 2026
Merged

[#532] Todo 카테고리가 무지성 fetch되는 현상을 해결한다#562
opficdev merged 19 commits into
developfrom
fix/#532-fetch

Conversation

@opficdev

@opficdev opficdev commented Jun 8, 2026

Copy link
Copy Markdown
Owner

🔗 연관된 이슈

🎯 의도

  • 앱 최초 실행 시 TodoCategoryPreference 조회가 여러 경로에서 반복 호출되는 흐름 개선
  • 과도한 Firebase SDK 호출이 진행되어 프로젝트 비용 감소 목적

📝 작업 내용

📌 요약

  • TodoCategoryPreferenceResponseUserDefaultsStore에 저장 가능한 캐시 대상으로 정리
  • 로그인 세션 확인 시 category preference를 먼저 캐싱한 뒤 앱/위젯 세션 상태를 전파하도록 수정
  • Todo, TodoCategory, PushNotification 조회 경로에서 category preference 캐시 사용
  • 위젯 snapshot 조회가 TodoRepository를 거치지 않고 TodoService를 직접 사용하도록 정리
  • RootViewModel/AuthSessionRepository의 중복 세션 이벤트 처리 방지

🔍 상세

  • UserDefaultsStore에 Codable value 저장/조회 API 추가
  • TodoCategoryPreferenceResponse에 Codable 채택
  • AuthSessionRepositoryImpl에서 signed-in 상태일 때 category preference 캐싱 후 session state publish
  • sign-out 상태에서는 category preference 캐시 제거
  • AuthSessionStateProvider를 통해 캐싱 완료 이후 위젯 세션 동기화 흐름 연결
  • TodoRepositoryImpl, TodoCategoryRepositoryImpl, PushNotificationRepositoryImpl에서 동일한 UserDefaults key 기반 category preference 캐시 사용
  • WidgetTodoSnapshotRepositoryImpl은 category resolve가 필요 없으므로 TodoRepository 의존 제거 후 TodoService 응답을 snapshot으로 직접 매핑
  • RootViewModel의 session/network/theme 구독을 init에서 제거하고 onAppear에서 1회만 시작하도록 변경
  • AuthSessionRepositoryImpl에서 auth state 중복 방출을 캐싱 side effect 이전에 제거
  • 관련 repository/widget 테스트 추가 및 spy 정리

📸 영상 / 이미지 (Optional)

개선 전 개선 후
개선 전 개선 후

@opficdev opficdev self-assigned this Jun 8, 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

이번 풀 request는 카테고리 선호도(Category Preference) 데이터의 캐싱 로직을 도입하고, 로그인 세션 상태 관리를 위해 AuthSessionStateProvider를 추가하며, WidgetTodoSnapshotRepositoryImplTodoRepository 대신 TodoService를 직접 사용하도록 리팩토링하는 변경 사항을 포함하고 있습니다. 리뷰 피드백으로는 1) AuthSessionRepositoryImpl에서 Combine 대신 AsyncStream을 사용하여 비동기 스트림을 처리할 것, 2) UserDefaultsStoreImpl에서 디코딩 실패 시 데이터를 강제로 삭제하는 로직이 데이터 유실을 유발할 수 있으므로 단순히 nil을 반환하도록 수정할 것, 3) 여러 레포지토리에 중복 구현된 캐싱 로직을 TodoCategoryRepository로 단일화하여 결합도를 낮추고 중복을 제거할 것을 권장합니다.

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 commented Jun 9, 2026

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

이번 풀 리퀘스트는 카테고리 선호도 데이터를 메모리에 캐싱하기 위해 MemoryCacheStore를 도입하고, 로그인 세션 상태를 관리하기 위해 AuthSessionStateProvider를 추가하는 변경 사항을 포함하고 있습니다. 또한, WidgetTodoSnapshotRepositoryImplTodoRepository 대신 TodoService를 직접 의존하도록 리팩토링되었으며, RootViewModel에서 화면 진입 시점에 관찰을 시작하도록 개선되었습니다. 리뷰 피드백으로는 MemoryCacheStoreImpl에서 불필요한 JSON 직렬화/역직렬화 오버헤드를 제거하고 NSLock을 사용하여 우선순위 역전을 방지할 것과, AuthSessionRepositoryImpl에서 FutureTask를 혼용하는 Combine 안티패턴을 개선하여 구조를 단순화할 것을 제안했습니다.

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/AuthSessionRepositoryImpl.swift Outdated
@opficdev opficdev merged commit bdcd1bc into develop Jun 9, 2026
5 checks passed
@opficdev opficdev deleted the fix/#532-fetch branch June 9, 2026 01:09
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