Skip to content

Conversation

@oungsi2000
Copy link
Contributor

#️⃣ 이슈 번호

#46


🛠️ 작업 내용

//FestivalNotificationRepository
override suspend fun deleteFestivalNotification(): Result<Unit> {
    val festivalId =
        festivalLocalDataSource.getFestivalId() ?: return Result.failure(
            IllegalStateException(),
        )
    val festivalNotificationId =
        festivalNotificationLocalDataSource.getFestivalNotificationId(festivalId)
    val response =
        festivalNotificationDataSource.deleteFestivalNotification(festivalNotificationId)
    festivalNotificationLocalDataSource.deleteFestivalNotificationId(festivalId)

    return response.toResult()
}
  1. 해당 코드에서 festivalNotificationDataSource.deleteFestivalNotification(festivalNotificationId)가 삭제에 실패하더라도 로컬 데이터소스에 삭제를 요청합니다.

이를 mapCatching으로 감싸서 서버에서 삭제를 실패했을 때만 로컬 데이터소스에 삭제를 요청합니다.

  1. 다만 로컬 데이터 저장, 삭제에 실패했을 시에는 별도의 복구 로직을 실행하지 않습니다.
  2. 처음 SettingViewModel이 생성되었을 때, 서버와 동기화하여 isAllowed, festivalNotificationId를 갱신합니다. (서버 통신 전에는 LocalDatasource의 값을 사용하고 추후 업데이트 합니다)

아직 스낵바 PR이 머지 전이라 스낵바는 뜨지 않습니다.


🙇🏻 중점 리뷰 요청

  • 특히 확인이 필요한 부분, 고민했던 부분 등을 적어주세요.

📸 이미지 첨부 (Optional)

앱 실행 시 서버로부터 사용자의 축제 알림 구독 목록을 가져와 로컬 상태와 동기화하는 기능을 추가했습니다. 이를 통해 다른 기기에서 알림 설정을 변경했거나, 앱을 재설치했을 때도 정확한 알림 수신 동의 상태가 반영되도록 개선했습니다.

- **`FestivalNotificationService.kt` 수정:**
    - `GET /festivals/notifications/{deviceId}` API를 호출하는 `getFestivalNotification` 함수를 추가하여 특정 기기에 등록된 모든 축제 알림 목록을 조회하는 기능을 구현했습니다.

- **`FestivalNotificationDataSource.kt` & `FestivalNotificationDataSourceImpl.kt` 수정:**
    - `FestivalNotificationService`의 변경 사항을 반영하여 `getFestivalNotification` 함수를 인터페이스와 구현체에 추가했습니다.

- **`FestivalNotificationRepository.kt` & `FestivalNotificationRepositoryImpl.kt` 수정:**
    - `syncFestivalNotificationIsAllow` 함수를 새로 추가했습니다.
    - 이 함수는 서버에서 현재 기기의 알림 구독 목록을 가져온 뒤, 현재 선택된 축제에 대한 구독 여부를 확인하여 로컬 데이터(SharedPreferences)를 갱신합니다.
    - 구독 중인 경우 `festivalNotificationId`를 로컬에 저장하고, 아닌 경우 삭제합니다.
    - `saveFestivalNotification`, `deleteFestivalNotification` 등 기존 로직의 예외 처리와 가독성을 개선했습니다.

- **`SettingViewModel.kt` 수정:**
    - `init` 블록에서 `festivalNotificationRepository.syncFestivalNotificationIsAllow()`를 호출하여, 설정 화면 진입 시 알림 동의 상태를 서버와 동기화하도록 로직을 추가했습니다.
기기 변경 또는 앱 재설치 시에도 축제 알림 설정 상태가 유지되도록, 앱 시작 시 서버와 알림 설정 상태를 동기화하는 기능을 추가했습니다.

- **`SettingViewModel.kt` 수정:**
    - ViewModel이 생성될 때(`init` 블록) `festivalNotificationRepository.syncFestivalNotificationIsAllow()`를 호출하여 서버의 알림 등록 상태를 가져와 로컬 데이터와 동기화합니다.
    - 동기화된 상태를 바탕으로 알림 허용 여부 UI(`uiState`)를 갱신합니다.

- **`FestivalNotificationRepositoryTest.kt` 추가:**
    - `FestivalNotificationRepository`의 동기화 로직에 대한 단위 테스트를 작성했습니다.
    - **주요 테스트 시나리오:**
        - 서버에 알림이 등록되어 있을 때, 로컬 DB에 알림 ID와 허용 상태(`true`)를 저장하는지 확인합니다.
        - 서버에 알림이 등록되어 있지 않을 때, 로컬 DB의 알림 ID를 삭제하고 허용 상태(`false`)를 저장하는지 확인합니다.
        - 알림 ID 저장 및 삭제 시, 서버 API 호출 성공 여부에 따라 로컬 데이터가 올바르게 처리되는지 검증합니다.

- **`RegisteredFestivalNotificationResponse.kt` 추가:**
    - 서버에서 등록된 축제 알림 목록을 받아오기 위한 새로운 데이터 모델 클래스를 정의했습니다.
@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@etama123 etama123 left a comment

Choose a reason for hiding this comment

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

👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants