[#450] Solve multiple calls to Play Core with LaunchedEffect
This commit is contained in:
parent
0dfd8d1e22
commit
b4bad94068
|
@ -13,6 +13,7 @@ import androidx.annotation.VisibleForTesting
|
|||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
|
@ -386,8 +387,6 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
@Composable
|
||||
private fun WrapCheckForUpdate() {
|
||||
// and then check for an app update asynchronously
|
||||
checkUpdateViewModel.checkForAppUpdate()
|
||||
val updateInfo = checkUpdateViewModel.updateInfo.collectAsState().value
|
||||
|
||||
updateInfo?.let {
|
||||
|
@ -395,6 +394,12 @@ class MainActivity : ComponentActivity() {
|
|||
WrapUpdate(updateInfo)
|
||||
}
|
||||
}
|
||||
|
||||
// Check for an app update asynchronously. We create an effect that matches the activity
|
||||
// lifecycle. If the wrapping compose recomposes, the check shouldn't run again.
|
||||
LaunchedEffect(true) {
|
||||
checkUpdateViewModel.checkForAppUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
Loading…
Reference in New Issue