For migration, put the selected source at the top of the search list instead of excluding it (#1542)

* For migration, put the selected source at the top of the search list rather than excluding it

* Indicate which source is currently selected during migration

Currently uses ▶
This commit is contained in:
FlaminSarge
2018-09-21 00:51:10 -07:00
committed by inorichi
parent 3c1179d27b
commit 353ccbd444
4 changed files with 31 additions and 13 deletions
@@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.migration
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchCardItem
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchItem
import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchPresenter
class SearchPresenter(
@@ -10,8 +12,13 @@ class SearchPresenter(
) : CatalogueSearchPresenter(initialQuery) {
override fun getEnabledSources(): List<CatalogueSource> {
// Filter out the source of the selected manga
// Put the source of the selected manga at the top
return super.getEnabledSources()
.filterNot { it.id == manga.source }
.sortedByDescending { it.id == manga.source }
}
}
override fun createCatalogueSearchItem(source: CatalogueSource, results: List<CatalogueSearchCardItem>?): CatalogueSearchItem {
//Set the catalogue search item as highlighted if the source matches that of the selected manga
return CatalogueSearchItem(source, results, source.id == manga.source)
}
}