File tree Expand file tree Collapse file tree
src/main/kotlin/com/theapache64/stackzy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ fun main() {
4040 val appArgs = AppArgs (
4141 appName = " Stackzy" ,
4242 version = " v1.2.2" ,
43- versionCode = 20220124
43+ versionCode = 20210724
4444 )
4545
4646 // Passing args
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.fillMaxSize
66import androidx.compose.foundation.layout.padding
77import androidx.compose.foundation.layout.size
88import androidx.compose.runtime.Composable
9+ import androidx.compose.runtime.LaunchedEffect
910import androidx.compose.runtime.collectAsState
1011import androidx.compose.runtime.getValue
1112import androidx.compose.ui.Alignment
@@ -29,11 +30,12 @@ fun SplashScreen(
2930 val isSyncFinished by splashViewModel.isSyncFinished.collectAsState()
3031 val syncFailedReason by splashViewModel.syncFailedMsg.collectAsState()
3132 val syncMessage by splashViewModel.syncMsg.collectAsState()
32- val shouldUpdate by splashViewModel.shouldUpdate.collectAsState()
33+ val shouldUpdate by splashViewModel.shouldUpdate.collectAsState(initial = false )
3334
34- if (shouldUpdate) {
35- onUpdateNeeded()
36- return
35+ LaunchedEffect (shouldUpdate) {
36+ if (shouldUpdate) {
37+ onUpdateNeeded()
38+ }
3739 }
3840
3941 if (isSyncFinished) {
Original file line number Diff line number Diff line change @@ -7,9 +7,11 @@ import com.theapache64.stackzy.data.repo.ConfigRepo
77import com.theapache64.stackzy.data.repo.FunFactsRepo
88import com.theapache64.stackzy.data.repo.LibrariesRepo
99import com.theapache64.stackzy.data.util.calladapter.flow.Resource
10+ import com.theapache64.stackzy.util.flow.mutableEventFlow
1011import com.toxicbakery.logging.Arbor
1112import kotlinx.coroutines.CoroutineScope
1213import kotlinx.coroutines.flow.MutableStateFlow
14+ import kotlinx.coroutines.flow.SharedFlow
1315import kotlinx.coroutines.flow.StateFlow
1416import kotlinx.coroutines.launch
1517import kotlinx.coroutines.flow.collect
@@ -150,13 +152,13 @@ class SplashViewModel @Inject constructor(
150152 }
151153
152154
153- private val _shouldUpdate = MutableStateFlow ( false )
154- val shouldUpdate: StateFlow <Boolean > = _shouldUpdate
155+ private val _shouldUpdate = mutableEventFlow< Boolean >( )
156+ val shouldUpdate: SharedFlow <Boolean > = _shouldUpdate
155157
156158 private fun verifyConfig (config : Config ): Boolean {
157159 val isUpdateNeeded = App .appArgs.versionCode < config.mandatoryVersionCode // currentVersion < mandatoryVersion
158160 return if (isUpdateNeeded) {
159- _shouldUpdate .value = true
161+ _shouldUpdate .tryEmit( true )
160162 false
161163 } else {
162164 true
Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ class NavHostComponent(
257257 * Invoked when an update is necessary
258258 */
259259 private fun onUpdateNeeded () {
260+ println (" Update needed" )
260261 router.push(Config .Update )
261262 }
262263
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2021 Boil (https://github.com/theapache64/boil)
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package com.theapache64.stackzy.util.flow
17+
18+ import kotlinx.coroutines.flow.MutableSharedFlow
19+
20+ /* *
21+ * To fire events.
22+ * This flow won't fire the last value for each collect call.
23+ * This observer will only be invoked on `tryEmit` calls.
24+ * (replacement for SingleLiveEvent :D)
25+ * Created by theapache64 : Jan 08 Fri,2021 @ 01:40
26+ */
27+ fun <T > mutableEventFlow (): MutableSharedFlow <T > {
28+ return MutableSharedFlow (
29+ replay = 0 ,
30+ extraBufferCapacity = 1
31+ )
32+ }
You canβt perform that action at this time.
0 commit comments