Skip to content

Commit 336497d

Browse files
committed
🌟 add isDown feature flag
1 parent 772c79c commit 336497d

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎data/src/main/kotlin/com/theapache64/stackzy/data/remote/Config.kt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ data class Config(
1717
val isPlayStoreEnabled: Boolean,
1818
@Json(name = "is_libs_tracking_enabled")
1919
val isLibsTrackingEnabled: Boolean,
20+
@Json(name = "is_down")
21+
val isDown: Boolean,
22+
@Json(name = "down_reason")
23+
val downReason: String,
2024
)

‎src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashScreen.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.theapache64.stackzy.ui.feature.splash
22

3+
import androidx.compose.desktop.ui.tooling.preview.Preview
34
import androidx.compose.foundation.ExperimentalFoundationApi
45
import androidx.compose.foundation.layout.Box
56
import androidx.compose.foundation.layout.fillMaxSize
@@ -16,6 +17,7 @@ import com.theapache64.stackzy.ui.common.ErrorSnackBar
1617
import com.theapache64.stackzy.ui.common.LoadingText
1718
import com.theapache64.stackzy.ui.common.Logo
1819

20+
1921
/**
2022
* Renders SplashScreen
2123
*/

‎src/main/kotlin/com/theapache64/stackzy/ui/feature/splash/SplashViewModel.kt‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import kotlinx.coroutines.CoroutineScope
1313
import kotlinx.coroutines.flow.MutableStateFlow
1414
import kotlinx.coroutines.flow.SharedFlow
1515
import kotlinx.coroutines.flow.StateFlow
16-
import kotlinx.coroutines.launch
1716
import kotlinx.coroutines.flow.collect
17+
import kotlinx.coroutines.launch
1818
import java.io.IOException
1919
import javax.inject.Inject
2020

@@ -156,13 +156,20 @@ class SplashViewModel @Inject constructor(
156156
val shouldUpdate: SharedFlow<Boolean> = _shouldUpdate
157157

158158
private fun verifyConfig(config: Config): Boolean {
159+
// Checking if app is down or not
160+
if (config.isDown) {
161+
_syncFailedMsg.tryEmit(config.downReason)
162+
return false
163+
}
164+
165+
// Checking if update needed
159166
val isUpdateNeeded = App.appArgs.versionCode < config.mandatoryVersionCode // currentVersion < mandatoryVersion
160-
return if (isUpdateNeeded) {
167+
if (isUpdateNeeded) {
161168
_shouldUpdate.tryEmit(true)
162-
false
163-
} else {
164-
true
169+
return false
165170
}
171+
172+
return true
166173
}
167174

168175
private suspend fun checkAndFixAdb(

0 commit comments

Comments
 (0)