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 -> {
val sourceExtra = groupExtra.nullIfBlank()
val source = sourceManager.getCatalogueSources().find { it.name == sourceExtra }
if (source != null) libraryManga.filter { it.source == source.id } else emptyList()
val sourceExtra = groupExtra.nullIfBlank()?.toIntOrNull()
val source = libraryManga.map { it.source }
.distinct()
.sorted()
.getOrNull(sourceExtra ?: -1)
if (source != null) libraryManga.filter { it.source == source } else emptyList()
}
LibraryGroup.BY_STATUS -> {
val statusExtra = groupExtra?.toIntOrNull() ?: -1

View File

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

View File

@ -836,7 +836,12 @@ class LibraryPresenter(
grouping += Triple(SManga.COMPLETED.toString(), SManga.COMPLETED, context.getString(R.string.completed))
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 ->
libraryManga
.map { it.manga.source }
.distinct()
.sorted()
.forEachIndexed { index, sourceLong ->
grouping += Triple(sourceLong.toString(), index, sourceManager.getOrStub(sourceLong).name)
}
LibraryGroup.BY_TRACK_STATUS -> {