Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 코스 상세페이지 / 이전 화면으로 돌아갔을 때 변경사항 바로 반영되도록 #334

Merged
merged 9 commits into from
Feb 16, 2024

Conversation

leeeha
Copy link
Member

@leeeha leeeha commented Feb 16, 2024

📌 개요

✨ 작업 내용

코스 상세페이지에서 본인이 업로드한 코스인 경우, 수정/삭제가 가능합니다. 상세페이지에서 이런 변경사항이 발생했을 때, 이전 화면에 바로 반영되도록 구현했습니다.

  • 코스 발견: DiscoverFragment, DiscoverMultiViewAdapter
  • 코스 검색: DiscoverSearchActivity, DiscoverSearchAdapter
  • 마이페이지 내가 업로드한 코스: MyUploadActivity, MyUploadAdapter
private fun navigateToPreviousScreen() {
    if (isFromDeepLink) {
        navigateToMainScreenWithBundle()
        isFromDeepLink = false
        return
    }

    when (rootScreen) {
        COURSE_STORAGE_SCRAP -> MainActivity.updateStorageScrapScreen()
        COURSE_DISCOVER -> setActivityResult<MainActivity>()
        COURSE_DISCOVER_SEARCH -> setActivityResult<DiscoverSearchActivity>()
        MY_PAGE_UPLOAD_COURSE -> setActivityResult<MyUploadActivity>()
    }

    finish()
    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
}

private inline fun <reified E : Activity> setActivityResult() {
    val updatedCourse = EditableDiscoverCourse(
        title = viewModel.title,
        scrap = binding.ivCourseDetailScrap.isSelected,
        isDeleted = viewModel.courseDeleteState.value is UiStateV2.Success
    )

    Intent(this@CourseDetailActivity, E::class.java).apply {
        putExtra(EXTRA_EDITABLE_DISCOVER_COURSE, updatedCourse)
        setResult(RESULT_OK, this)
    }
}

✨ PR 포인트

특정 항목의 변경사항을 이전 화면에 바로 반영시키는, 또 다른 방법이나 아이디어가 있으시다면 언제든 피드백 부탁드립니다!

@leeeha leeeha added 하은 🐰 하은 담당 FIX 💥 버그 및 오류 해결 labels Feb 16, 2024
@leeeha leeeha self-assigned this Feb 16, 2024
Copy link
Contributor

@unam98 unam98 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 :)

…into feature/fix-detail-to-discover-refresh

# Conflicts:
#	app/src/main/java/com/runnect/runnect/presentation/detail/CourseDetailActivity.kt
@leeeha leeeha merged commit ac0544d into develop Feb 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIX 💥 버그 및 오류 해결 하은 🐰 하은 담당
Projects
None yet
2 participants