Fix issue 158, some sources not updating with group by source

This commit is contained in:
Jobobby04 2022-01-15 19:28:05 -05:00
parent 6b3813bb9a
commit 18a119e9cf
3 changed files with 16 additions and 8 deletions

View File

@ -327,9 +327,13 @@ class LibraryUpdateService(
} }
} }
LibraryGroup.BY_SOURCE -> { LibraryGroup.BY_SOURCE -> {
val sourceExtra = groupExtra.nullIfBlank() val sourceExtra = groupExtra.nullIfBlank()?.toIntOrNull()
val source = sourceManager.getCatalogueSources().find { it.name == sourceExtra } val source = libraryManga.map { it.source }
if (source != null) libraryManga.filter { it.source == source.id } else emptyList() .distinct()
.sorted()
.getOrNull(sourceExtra ?: -1)
if (source != null) libraryManga.filter { it.source == source } else emptyList()
} }
LibraryGroup.BY_STATUS -> { LibraryGroup.BY_STATUS -> {
val statusExtra = groupExtra?.toIntOrNull() ?: -1 val statusExtra = groupExtra?.toIntOrNull() ?: -1

View File

@ -405,8 +405,7 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
// SY --> // SY -->
private fun getGroupExtra() = when (controller.presenter.groupType) { private fun getGroupExtra() = when (controller.presenter.groupType) {
LibraryGroup.BY_DEFAULT -> null LibraryGroup.BY_DEFAULT -> null
LibraryGroup.BY_SOURCE -> category.name LibraryGroup.BY_SOURCE, LibraryGroup.BY_STATUS, LibraryGroup.BY_TRACK_STATUS -> category.id.toString()
LibraryGroup.BY_STATUS, LibraryGroup.BY_TRACK_STATUS -> category.id.toString()
else -> null else -> null
} }

View File

@ -836,9 +836,14 @@ class LibraryPresenter(
grouping += Triple(SManga.COMPLETED.toString(), SManga.COMPLETED, context.getString(R.string.completed)) grouping += Triple(SManga.COMPLETED.toString(), SManga.COMPLETED, context.getString(R.string.completed))
grouping += Triple(SManga.UNKNOWN.toString(), SManga.UNKNOWN, context.getString(R.string.unknown)) grouping += Triple(SManga.UNKNOWN.toString(), SManga.UNKNOWN, context.getString(R.string.unknown))
} }
LibraryGroup.BY_SOURCE -> libraryManga.distinctBy { it.manga.source }.map { it.manga.source }.forEachIndexed { index, sourceLong -> LibraryGroup.BY_SOURCE ->
grouping += Triple(sourceLong.toString(), index, sourceManager.getOrStub(sourceLong).name) libraryManga
} .map { it.manga.source }
.distinct()
.sorted()
.forEachIndexed { index, sourceLong ->
grouping += Triple(sourceLong.toString(), index, sourceManager.getOrStub(sourceLong).name)
}
LibraryGroup.BY_TRACK_STATUS -> { LibraryGroup.BY_TRACK_STATUS -> {
grouping += Triple("1", 1, context.getString(R.string.reading)) grouping += Triple("1", 1, context.getString(R.string.reading))
grouping += Triple("2", 2, context.getString(R.string.repeating)) grouping += Triple("2", 2, context.getString(R.string.repeating))