From c77cb4cb3c7bc7b7df4b5545f6cfe26849d53862 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Fri, 18 Aug 2023 10:13:56 +0300 Subject: [PATCH] Fix sources migration --- .../kotatsu/core/db/migrations/Migration16To17.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration16To17.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration16To17.kt index 39bb68184..cccbdd9e8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration16To17.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration16To17.kt @@ -21,15 +21,18 @@ class Migration16To17(context: Context) : Migration(16, 17) { continue } val name = source.name - var isEnabled = name !in hiddenSources + val isHidden = name in hiddenSources var sortKey = order.indexOf(name) if (sortKey == -1) { - sortKey = order.size + source.ordinal - isEnabled = false + if (isHidden) { + sortKey = order.size + source.ordinal + } else { + continue + } } database.execSQL( "INSERT INTO `sources` (`source`, `enabled`, `sort_key`) VALUES (?, ?, ?)", - arrayOf(name, isEnabled.toInt(), sortKey), + arrayOf(name, (!isHidden).toInt(), sortKey), ) } }