Skip to content

Commit

Permalink
[#405] 설정 화면 버전 불러오기 실패한 경우 UI 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nodobi committed Oct 7, 2024
1 parent 2019f92 commit 5d75236
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
16 changes: 6 additions & 10 deletions koin/src/main/java/in/koreatech/koin/ui/setting/SettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import `in`.koreatech.koin.R
import `in`.koreatech.koin.constant.URL
import `in`.koreatech.koin.core.activity.ActivityBase
import `in`.koreatech.koin.core.appbar.AppBarBase
import `in`.koreatech.koin.core.toast.ToastUtil
import `in`.koreatech.koin.databinding.ActivitySettingBinding
import `in`.koreatech.koin.ui.changepassword.ChangePasswordContract
import `in`.koreatech.koin.ui.login.LoginActivity
Expand Down Expand Up @@ -86,7 +85,7 @@ class SettingActivity : ActivityBase() {
loginSnackBar.show()
}
svNotification.setOnSettingClickListener {
if(viewModel.isStudent) {
if (viewModel.isStudent) {
startActivity(Intent(this@SettingActivity, NotificationActivity::class.java))
} else
loginSnackBar.show()
Expand Down Expand Up @@ -135,15 +134,12 @@ class SettingActivity : ActivityBase() {
binding.tvClientVersion.text = null
binding.tvAppVersion.text = null
}
}
}
}
}

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.versionError.collect {
ToastUtil.getInstance().makeShort(R.string.version_check_failed)
is VersionState.Failure -> {
binding.tvClientVersion.text = null
binding.tvAppVersion.text = null
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import `in`.koreatech.koin.domain.model.user.User
import `in`.koreatech.koin.domain.usecase.user.GetUserInfoUseCase
import `in`.koreatech.koin.domain.usecase.version.GetLatestVersionUseCase
import `in`.koreatech.koin.domain.util.onSuccess
import `in`.koreatech.koin.util.EventFlow
import `in`.koreatech.koin.util.MutableEventFlow
import `in`.koreatech.koin.util.asEventFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand All @@ -25,9 +22,6 @@ class SettingViewModel @Inject constructor(
private val _versionState: MutableStateFlow<VersionState> = MutableStateFlow(VersionState.Init)
val versionState: StateFlow<VersionState> get() = _versionState.asStateFlow()

private val _versionError = MutableEventFlow<Unit>()
val versionError: EventFlow<Unit> = _versionError.asEventFlow()

private val _userInfo: MutableStateFlow<User> = MutableStateFlow(User.Anonymous)

val isStudent: Boolean get() = _userInfo.value.isStudent
Expand Down Expand Up @@ -58,7 +52,7 @@ class SettingViewModel @Inject constructor(
}
}
.onFailure {
_versionError.emit(Unit)
_versionState.value = VersionState.Failure
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ sealed class VersionState {
data class Outdated(val currentVersion: String, val latestVersion: String) : VersionState()
data class Latest(val currentVersion: String): VersionState()
data object Init: VersionState()
data object Failure: VersionState()
}

0 comments on commit 5d75236

Please sign in to comment.