mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Keep the migration screen up for at least a second
This commit is contained in:
@@ -97,6 +97,7 @@ import eu.kanade.tachiyomi.util.system.updaterEnabled
|
||||
import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -126,7 +127,9 @@ import tachiyomi.presentation.core.i18n.stringResource
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.Instant
|
||||
import kotlin.time.TimeSource
|
||||
import kotlin.time.times
|
||||
|
||||
class MainActivity : BaseActivity() {
|
||||
@@ -181,7 +184,19 @@ class MainActivity : BaseActivity() {
|
||||
setComposeContent {
|
||||
val appMigrating by isAppMigrating.collectAsState()
|
||||
val databaseMigrating by databaseRepository.isMigrating.collectAsState()
|
||||
if (appMigrating || databaseMigrating) {
|
||||
val migrating = appMigrating || databaseMigrating
|
||||
var migratingSince by remember { mutableStateOf(if (migrating) TimeSource.Monotonic.markNow() else null) }
|
||||
LaunchedEffect(migrating) {
|
||||
val since = migratingSince
|
||||
if (migrating) {
|
||||
if (since == null) migratingSince = TimeSource.Monotonic.markNow()
|
||||
} else if (since != null) {
|
||||
// A migration that finishes right away would otherwise only flash the screen
|
||||
delay(MIGRATING_SCREEN_MIN_DURATION - since.elapsedNow())
|
||||
migratingSince = null
|
||||
}
|
||||
}
|
||||
if (migrating || migratingSince != null) {
|
||||
AppMigratingScreen()
|
||||
// Release the splash screen so the reason for the wait shows
|
||||
LaunchedEffect(Unit) { ready = true }
|
||||
@@ -633,3 +648,5 @@ class MainActivity : BaseActivity() {
|
||||
private const val SPLASH_MIN_DURATION = 500 // ms
|
||||
private const val SPLASH_MAX_DURATION = 5000 // ms
|
||||
private const val SPLASH_EXIT_ANIM_DURATION = 400L // ms
|
||||
|
||||
private val MIGRATING_SCREEN_MIN_DURATION = 1.seconds
|
||||
|
||||
Reference in New Issue
Block a user