Skip to content

Commit

Permalink
#137 / 구독해서 적절한 액션 취하기
Browse files Browse the repository at this point in the history
  • Loading branch information
taeheeL committed Dec 6, 2023
1 parent a4159c2 commit ad0e6b6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/src/main/java/sopt/uni/presentation/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import sopt.uni.R
import sopt.uni.databinding.ActivityHomeBinding
import sopt.uni.presentation.common.content.ErrorCodeState
import sopt.uni.presentation.common.content.UNDECIDED
import sopt.uni.presentation.history.HistoryActivity
import sopt.uni.presentation.mypage.MypageSettingActivity
Expand All @@ -33,6 +34,7 @@ class HomeActivity : BindingActivity<ActivityHomeBinding>(R.layout.activity_home

binding.viewModel = homeViewModel

collectErrorCode()
moveToHistory()
getRoundResult()
moveToShortGame()
Expand Down Expand Up @@ -122,4 +124,20 @@ class HomeActivity : BindingActivity<ActivityHomeBinding>(R.layout.activity_home
showSnackbar(binding.root, getString(R.string.prepare_heart_function))
}
}

private fun collectErrorCode() {
lifecycleScope.launch {
homeViewModel.errorState.collect {
when (it) {
is ErrorCodeState.NoToken -> {
showToast("존재하지 않는 사용자입니다. 다시 로그인해주세요")
}

else -> {
Timber.e("error: $it")
}
}
}
}
}
}

0 comments on commit ad0e6b6

Please sign in to comment.