Skip to content

Commit

Permalink
fix stream agreement no display
Browse files Browse the repository at this point in the history
  • Loading branch information
aderan committed Sep 18, 2024
1 parent 3ee4c6f commit 1560a33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/io/agora/flat/data/AppEnv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {
loginConfig = LoginConfig(google = false),

showIcp = true,
showStreamAgreement = true,
)

envMap[ENV_CN_PROD] = EnvItem(
Expand All @@ -82,6 +83,7 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {
loginConfig = LoginConfig(google = false),

showIcp = true,
showStreamAgreement = true,
)

envMap[ENV_SG_PROD] = EnvItem(
Expand Down Expand Up @@ -184,6 +186,8 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {

val showIcp get() = currentEnvItem.showIcp

val showStreamAgreement get() = currentEnvItem.showStreamAgreement

val agreementsUrl get() = "https://flat-storage.oss-cn-hangzhou.aliyuncs.com/versions/latest/stable/android/agreements.json"

data class EnvItem(
Expand All @@ -203,6 +207,7 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {
val loginConfig: LoginConfig = LoginConfig(),

val showIcp: Boolean = false,
val showStreamAgreement: Boolean = false,
)
}

Expand Down
19 changes: 15 additions & 4 deletions app/src/main/java/io/agora/flat/ui/viewmodel/SettingsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.agora.flat.data.repository.MiscRepository
import io.agora.flat.data.repository.UserRepository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -34,12 +35,22 @@ class SettingsViewModel @Inject constructor(

init {
viewModelScope.launch {
_state.value = _state.value.copy(versionCheckResult = versionChecker.forceCheck())
val checkResult = versionChecker.forceCheck()
_state.update {
it.copy(versionCheckResult = checkResult)
}
}

viewModelScope.launch {
val value = miscRepository.getStreamAgreement()
_state.value = _state.value.copy(isAgreeStream = value)
if (env.showStreamAgreement) {
_state.update {
it.copy(isAgreeStream = false)
}
viewModelScope.launch {
val value = miscRepository.getStreamAgreement() ?: false
_state.update {
it.copy(isAgreeStream = value)
}
}
}
}

Expand Down

0 comments on commit 1560a33

Please sign in to comment.