|
|
|
|
@ -16,6 +16,7 @@ fun MangaDetails.mapChapters(
|
|
|
|
|
branch: String?,
|
|
|
|
|
bookmarks: List<Bookmark>,
|
|
|
|
|
isGrid: Boolean,
|
|
|
|
|
isDownloadedOnly: Boolean,
|
|
|
|
|
): List<ChapterListItem> {
|
|
|
|
|
val remoteChapters = chapters[branch].orEmpty()
|
|
|
|
|
val localChapters = local?.manga?.getChapters(branch).orEmpty()
|
|
|
|
|
@ -35,19 +36,21 @@ fun MangaDetails.mapChapters(
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
var isUnread = currentChapterId !in ids
|
|
|
|
|
for (chapter in remoteChapters) {
|
|
|
|
|
val local = localMap?.remove(chapter.id)
|
|
|
|
|
if (chapter.id == currentChapterId) {
|
|
|
|
|
isUnread = true
|
|
|
|
|
if (!isDownloadedOnly || local?.manga?.chapters == null) {
|
|
|
|
|
for (chapter in remoteChapters) {
|
|
|
|
|
val local = localMap?.remove(chapter.id)
|
|
|
|
|
if (chapter.id == currentChapterId) {
|
|
|
|
|
isUnread = true
|
|
|
|
|
}
|
|
|
|
|
result += (local ?: chapter).toListItem(
|
|
|
|
|
isCurrent = chapter.id == currentChapterId,
|
|
|
|
|
isUnread = isUnread,
|
|
|
|
|
isNew = isUnread && result.size >= newFrom,
|
|
|
|
|
isDownloaded = local != null,
|
|
|
|
|
isBookmarked = chapter.id in bookmarked,
|
|
|
|
|
isGrid = isGrid,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
result += (local ?: chapter).toListItem(
|
|
|
|
|
isCurrent = chapter.id == currentChapterId,
|
|
|
|
|
isUnread = isUnread,
|
|
|
|
|
isNew = isUnread && result.size >= newFrom,
|
|
|
|
|
isDownloaded = local != null,
|
|
|
|
|
isBookmarked = chapter.id in bookmarked,
|
|
|
|
|
isGrid = isGrid,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
if (!localMap.isNullOrEmpty()) {
|
|
|
|
|
for (chapter in localMap.values) {
|
|
|
|
|
|