From 3f1d28c3833e6b868152149ed02b3fb8c54eccef Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Mon, 12 Aug 2024 03:21:17 +0600 Subject: [PATCH] Fix UI freeze after migration Fixes #938 --- .../java/mihon/core/migration/MigrationStrategyFactory.kt | 4 +--- app/src/main/java/mihon/core/migration/Migrator.kt | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/mihon/core/migration/MigrationStrategyFactory.kt b/app/src/main/java/mihon/core/migration/MigrationStrategyFactory.kt index 7e06fecb3d..0905cc086a 100644 --- a/app/src/main/java/mihon/core/migration/MigrationStrategyFactory.kt +++ b/app/src/main/java/mihon/core/migration/MigrationStrategyFactory.kt @@ -6,15 +6,13 @@ class MigrationStrategyFactory( ) { fun create(old: Int, new: Int): MigrationStrategy { - val versions = (old + 1)..new val strategy = when { old == 0 -> InitialMigrationStrategy( strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope), ) - old >= new -> NoopMigrationStrategy(false) else -> VersionRangeMigrationStrategy( - versions = versions, + versions = (old + 1)..new, strategy = DefaultMigrationStrategy(factory, migrationCompletedListener, Migrator.scope), ) } diff --git a/app/src/main/java/mihon/core/migration/Migrator.kt b/app/src/main/java/mihon/core/migration/Migrator.kt index 11f22a8c9b..2296aa0747 100644 --- a/app/src/main/java/mihon/core/migration/Migrator.kt +++ b/app/src/main/java/mihon/core/migration/Migrator.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.runBlocking object Migrator { private var result: Deferred? = null - val scope = CoroutineScope(Dispatchers.Main + Job()) + val scope = CoroutineScope(Dispatchers.IO + Job()) fun initialize( old: Int,