From e4942b0d931ec6b2ed5100fcef7791e103b5f9a7 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Mon, 24 Jul 2023 20:21:57 +0300 Subject: [PATCH] Fix new manga sources enabling --- .../org/koitharu/kotatsu/core/db/dao/MangaSourcesDao.kt | 4 ++-- .../main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/MangaSourcesDao.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/MangaSourcesDao.kt index ba0939de8..5d91447eb 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/MangaSourcesDao.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/dao/MangaSourcesDao.kt @@ -24,7 +24,7 @@ abstract class MangaSourcesDao { @Query("SELECT * FROM sources ORDER BY sort_key") abstract fun observeAll(): Flow> - @Query("SELECT MAX(sort_key) FROM sources") + @Query("SELECT IFNULL(MAX(sort_key),0) FROM sources") abstract suspend fun getMaxSortKey(): Int @Query("UPDATE sources SET enabled = 0") @@ -35,7 +35,7 @@ abstract class MangaSourcesDao { @Insert(onConflict = OnConflictStrategy.IGNORE) @Transaction - abstract suspend fun insertIfAbsent(entries: Iterable) + abstract suspend fun insertIfAbsent(entries: Collection) @Upsert abstract suspend fun upsert(entry: MangaSourceEntity) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt index fc90f1382..9b1757cb7 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/ui/MainViewModel.kt @@ -84,6 +84,6 @@ class MainViewModel @Inject constructor( } private fun observeNewSourcesCount() = sourcesRepository.observeNewSources() - .map { it.size } + .map { if (sourcesRepository.isSetupRequired()) 0 else it.size } .distinctUntilChanged() }