Deduplicate entries when browsing (#1957)

This commit is contained in:
AntsyLich
2025-04-03 01:48:54 +06:00
committed by GitHub
parent 2ce9fa0271
commit f81da3dcce
3 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
### Improved
- Significantly improve browsing speed (near instantaneous) ([@AntsyLich](https://github.com/AntsyLich)) ([#1946](https://github.com/mihonapp/mihon/pull/1946))
- Deduplicate entries when browsing ([@AntsyLich](https://github.com/AntsyLich)) ([#1957](https://github.com/mihonapp/mihon/pull/1957))
### Fixes
- Fix Bangumi search results including novels ([@MajorTanya](https://github.com/MajorTanya)) ([#1885](https://github.com/mihonapp/mihon/pull/1885))

View File

@ -165,7 +165,9 @@ abstract class SearchScreenModel(
source.getSearchManga(1, query, source.getFilterList())
}
val titles = page.mangas.map { it.toDomainManga(source.id) }
val titles = page.mangas
.map { it.toDomainManga(source.id) }
.distinctBy { it.url }
.let { networkToLocalManga(it) }
if (isActive) {

View File

@ -39,6 +39,8 @@ abstract class BaseSourcePagingSource(
private val networkToLocalManga: NetworkToLocalManga = Injekt.get(),
) : SourcePagingSource() {
private val seenManga = hashSetOf<String>()
abstract suspend fun requestNextPage(currentPage: Int): MangasPage
override suspend fun load(params: LoadParams<Long>): LoadResult<Long, Manga> {
@ -51,7 +53,9 @@ abstract class BaseSourcePagingSource(
?: throw NoResultsException()
}
val manga = mangasPage.mangas.map { it.toDomainManga(source.id) }
val manga = mangasPage.mangas
.map { it.toDomainManga(source.id) }
.filter { seenManga.add(it.url) }
.let { networkToLocalManga(it) }
LoadResult.Page(