delay launch with safe mode dialog

This commit is contained in:
qimiko committed 2024-02-08 22:11:33 -07:00
1 parent 41e3e0a133
commit 61c018ee0d
1 file changed
+10 -15
@@ -145,7 +145,7 @@ fun UpdateProgressIndicator(
message: String, message: String,
releaseViewModel: ReleaseViewModel, releaseViewModel: ReleaseViewModel,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
progress: Float? = null progress: (() -> Float)? = null
) { ) {
Column( Column(
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
@@ -159,9 +159,7 @@ fun UpdateProgressIndicator(
if (progress == null) { if (progress == null) {
LinearProgressIndicator() LinearProgressIndicator()
} else { } else {
LinearProgressIndicator( LinearProgressIndicator(progress = progress)
progress = { progress },
)
} }
TextButton( TextButton(
@@ -351,8 +349,6 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
) )
} }
is ReleaseViewModel.ReleaseUIState.InDownload -> { is ReleaseViewModel.ReleaseUIState.InDownload -> {
val progress = state.downloaded / state.outOf.toDouble()
val downloaded = remember(state.downloaded) { val downloaded = remember(state.downloaded) {
formatShortFileSize(context, state.downloaded) formatShortFileSize(context, state.downloaded)
} }
@@ -369,7 +365,10 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
), ),
modifier = modifier, modifier = modifier,
releaseViewModel = releaseViewModel, releaseViewModel = releaseViewModel,
progress = progress.toFloat() progress = {
val progress = state.downloaded / state.outOf.toDouble()
progress.toFloat()
}
) )
} }
is ReleaseViewModel.ReleaseUIState.InUpdateCheck -> { is ReleaseViewModel.ReleaseUIState.InUpdateCheck -> {
@@ -450,7 +449,7 @@ fun MainScreen(
) { ) {
val context = LocalContext.current val context = LocalContext.current
val shouldAutomaticallyLaunch = PreferenceUtils.useBooleanPreference( val shouldAutomaticallyLaunch by PreferenceUtils.useBooleanPreference(
preferenceKey = PreferenceUtils.Key.LOAD_AUTOMATICALLY preferenceKey = PreferenceUtils.Key.LOAD_AUTOMATICALLY
) )
@@ -493,15 +492,11 @@ fun MainScreen(
) )
if (gdInstalled && geodeInstalled) { if (gdInstalled && geodeInstalled) {
if (shouldAutomaticallyLaunch.value && !releaseViewModel.isInUpdate && !disableAutomaticLaunch) { val stopLaunch = releaseViewModel.isInUpdate || disableAutomaticLaunch || showSafeModeDialog
if (shouldAutomaticallyLaunch && !stopLaunch) {
val countdownTimer = useCountdownTimer( val countdownTimer = useCountdownTimer(
time = 3000, time = 3000,
onCountdownFinish = { onCountdownFinish = { beginLaunch = true }
// just in case this changed async
if (shouldAutomaticallyLaunch.value) {
beginLaunch = true
}
}
) )
if (countdownTimer != 0L) { if (countdownTimer != 0L) {