mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(chapter): Check if url already managed or not
This commit is contained in:
parent
834958a819
commit
d99476f9bf
1 changed files with 7 additions and 1 deletions
|
@ -77,9 +77,13 @@ suspend fun syncChaptersWithSource(
|
|||
}
|
||||
val toDelete = duplicates + notInSource
|
||||
|
||||
val managedUrls = mutableListOf<String>()
|
||||
|
||||
for (sourceChapter in sourceChapters) {
|
||||
val chapter = sourceChapter
|
||||
|
||||
if (chapter.url in managedUrls) continue
|
||||
|
||||
if (source is HttpSource) {
|
||||
source.prepareNewChapter(chapter, manga)
|
||||
}
|
||||
|
@ -108,6 +112,8 @@ suspend fun syncChaptersWithSource(
|
|||
toChange.add(update)
|
||||
}
|
||||
}
|
||||
|
||||
managedUrls.add(chapter.url)
|
||||
}
|
||||
|
||||
// Return if there's nothing to add, delete or change, avoid unnecessary db transactions.
|
||||
|
@ -137,7 +143,7 @@ suspend fun syncChaptersWithSource(
|
|||
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
||||
// Sources MUST return the chapters from most to less recent, which is common.
|
||||
var itemCount = toAdd.size
|
||||
var updatedToAdd = toAdd.distinctBy { it.url }.map { toAddItem ->
|
||||
var updatedToAdd = toAdd.map { toAddItem ->
|
||||
val chapter: Chapter = toAddItem.copy()
|
||||
|
||||
chapter.date_fetch = now + itemCount--
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue