Replace preference getter functions with properties (#3091)
This commit is contained in:
+7
-7
@@ -17,17 +17,17 @@ class CategoryPreferencesCleanupMigration : Migration {
|
||||
val getCategories = migrationContext.get<GetCategories>() ?: return@withIOContext false
|
||||
val allCategories = getCategories.await().map { it.id.toString() }.toSet()
|
||||
|
||||
val defaultCategory = libraryPreferences.defaultCategory().get()
|
||||
val defaultCategory = libraryPreferences.defaultCategory.get()
|
||||
if (defaultCategory.toString() !in allCategories) {
|
||||
libraryPreferences.defaultCategory().delete()
|
||||
libraryPreferences.defaultCategory.delete()
|
||||
}
|
||||
|
||||
val categoryPreferences = listOf(
|
||||
libraryPreferences.updateCategories(),
|
||||
libraryPreferences.updateCategoriesExclude(),
|
||||
downloadPreferences.removeExcludeCategories(),
|
||||
downloadPreferences.downloadNewChapterCategories(),
|
||||
downloadPreferences.downloadNewChapterCategoriesExclude(),
|
||||
libraryPreferences.updateCategories,
|
||||
libraryPreferences.updateCategoriesExclude,
|
||||
downloadPreferences.removeExcludeCategories,
|
||||
downloadPreferences.downloadNewChapterCategories,
|
||||
downloadPreferences.downloadNewChapterCategoriesExclude,
|
||||
)
|
||||
categoryPreferences.forEach { preference ->
|
||||
val ids = preference.get()
|
||||
|
||||
@@ -11,7 +11,7 @@ class InstallationIdMigration : Migration {
|
||||
|
||||
@OptIn(ExperimentalUuidApi::class)
|
||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean {
|
||||
val installationId = migrationContext.get<BasePreferences>()?.installationId() ?: return false
|
||||
val installationId = migrationContext.get<BasePreferences>()?.installationId ?: return false
|
||||
if (!installationId.isSet()) installationId.set(FeatureFlags.newInstallationId())
|
||||
return true
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ class TrustExtensionRepositoryMigration : Migration {
|
||||
val sourcePreferences = migrationContext.get<SourcePreferences>() ?: return@withIOContext false
|
||||
val extensionRepositoryRepository =
|
||||
migrationContext.get<ExtensionRepoRepository>() ?: return@withIOContext false
|
||||
for ((index, source) in sourcePreferences.extensionRepos().get().withIndex()) {
|
||||
for ((index, source) in sourcePreferences.extensionRepos.get().withIndex()) {
|
||||
try {
|
||||
extensionRepositoryRepository.upsertRepo(
|
||||
source,
|
||||
@@ -29,7 +29,7 @@ class TrustExtensionRepositoryMigration : Migration {
|
||||
logcat(LogPriority.ERROR, e) { "Error Migrating Extension Repo with baseUrl: $source" }
|
||||
}
|
||||
}
|
||||
sourcePreferences.extensionRepos().delete()
|
||||
sourcePreferences.extensionRepos.delete()
|
||||
return@withIOContext true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user