Skip to content

Commit 1560a33

Browse files
committed
fix stream agreement no display
1 parent 3ee4c6f commit 1560a33

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

app/src/main/java/io/agora/flat/data/AppEnv.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {
5959
loginConfig = LoginConfig(google = false),
6060

6161
showIcp = true,
62+
showStreamAgreement = true,
6263
)
6364

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

8485
showIcp = true,
86+
showStreamAgreement = true,
8587
)
8688

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

185187
val showIcp get() = currentEnvItem.showIcp
186188

189+
val showStreamAgreement get() = currentEnvItem.showStreamAgreement
190+
187191
val agreementsUrl get() = "https://flat-storage.oss-cn-hangzhou.aliyuncs.com/versions/latest/stable/android/agreements.json"
188192

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

205209
val showIcp: Boolean = false,
210+
val showStreamAgreement: Boolean = false,
206211
)
207212
}
208213

app/src/main/java/io/agora/flat/ui/viewmodel/SettingsViewModel.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import io.agora.flat.data.repository.MiscRepository
1313
import io.agora.flat.data.repository.UserRepository
1414
import kotlinx.coroutines.flow.MutableStateFlow
1515
import kotlinx.coroutines.flow.StateFlow
16+
import kotlinx.coroutines.flow.update
1617
import kotlinx.coroutines.launch
1718
import javax.inject.Inject
1819

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

3536
init {
3637
viewModelScope.launch {
37-
_state.value = _state.value.copy(versionCheckResult = versionChecker.forceCheck())
38+
val checkResult = versionChecker.forceCheck()
39+
_state.update {
40+
it.copy(versionCheckResult = checkResult)
41+
}
3842
}
3943

40-
viewModelScope.launch {
41-
val value = miscRepository.getStreamAgreement()
42-
_state.value = _state.value.copy(isAgreeStream = value)
44+
if (env.showStreamAgreement) {
45+
_state.update {
46+
it.copy(isAgreeStream = false)
47+
}
48+
viewModelScope.launch {
49+
val value = miscRepository.getStreamAgreement() ?: false
50+
_state.update {
51+
it.copy(isAgreeStream = value)
52+
}
53+
}
4354
}
4455
}
4556

0 commit comments

Comments
 (0)