Replace preference getter functions with properties (#3091)

This commit is contained in:
AntsyLich
2026-03-20 14:57:01 +06:00
committed by GitHub
parent 2f9edb551f
commit 87665736a9
126 changed files with 816 additions and 722 deletions
@@ -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
}
@@ -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
}
}