mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 00:05:08 +01:00
Recents page now shows the first newest chapter in 12 hours
This commit is contained in:
parent
0bcd8f2f68
commit
faa7cd3d26
@ -47,6 +47,11 @@ class RecentMangaHolder(
|
|||||||
item.mch.manga.date_added, Date().time, DateUtils.MINUTE_IN_MILLIS
|
item.mch.manga.date_added, Date().time, DateUtils.MINUTE_IN_MILLIS
|
||||||
).toString()
|
).toString()
|
||||||
)
|
)
|
||||||
|
item.mch.history.id == null -> body.context.getString(
|
||||||
|
R.string.updated_x, DateUtils.getRelativeTimeSpanString(
|
||||||
|
item.chapter.date_upload, Date().time, DateUtils.HOUR_IN_MILLIS
|
||||||
|
).toString()
|
||||||
|
)
|
||||||
item.chapter.id != item.mch.chapter.id -> body.context.getString(
|
item.chapter.id != item.mch.chapter.id -> body.context.getString(
|
||||||
if (notValidNum) R.string.last_read_x else R.string.last_read_chapter_x,
|
if (notValidNum) R.string.last_read_x else R.string.last_read_chapter_x,
|
||||||
if (notValidNum) item.mch.chapter.name else adapter.decimalFormat.format(item.mch.chapter.chapter_number) +
|
if (notValidNum) item.mch.chapter.name else adapter.decimalFormat.format(item.mch.chapter.chapter_number) +
|
||||||
@ -54,11 +59,6 @@ class RecentMangaHolder(
|
|||||||
item.mch.history.last_read, Date().time, DateUtils.MINUTE_IN_MILLIS
|
item.mch.history.last_read, Date().time, DateUtils.MINUTE_IN_MILLIS
|
||||||
)})"
|
)})"
|
||||||
)
|
)
|
||||||
item.mch.history.id == null -> body.context.getString(
|
|
||||||
R.string.updated_x, DateUtils.getRelativeTimeSpanString(
|
|
||||||
item.chapter.date_upload, Date().time, DateUtils.HOUR_IN_MILLIS
|
|
||||||
).toString()
|
|
||||||
)
|
|
||||||
!isSearch && item.chapter.pages_left > 0 -> itemView.resources.getQuantityString(
|
!isSearch && item.chapter.pages_left > 0 -> itemView.resources.getQuantityString(
|
||||||
R.plurals.pages_left, item.chapter.pages_left, item.chapter.pages_left
|
R.plurals.pages_left, item.chapter.pages_left, item.chapter.pages_left
|
||||||
) +
|
) +
|
||||||
|
@ -80,7 +80,8 @@ class RecentsPresenter(
|
|||||||
}
|
}
|
||||||
val pairs = mangaList.mapNotNull {
|
val pairs = mangaList.mapNotNull {
|
||||||
val chapter = if (it.chapter.read || it.chapter.id == null) getNextChapter(it.manga)
|
val chapter = if (it.chapter.read || it.chapter.id == null) getNextChapter(it.manga)
|
||||||
else it.chapter
|
else if (it.history.id == null) getFirstUpdatedChapter(it.manga, it.chapter)
|
||||||
|
else it.chapter
|
||||||
if (chapter == null) if (query.isNotEmpty() && it.chapter.id != null) Pair(
|
if (chapter == null) if (query.isNotEmpty() && it.chapter.id != null) Pair(
|
||||||
it, it.chapter
|
it, it.chapter
|
||||||
)
|
)
|
||||||
@ -92,7 +93,7 @@ class RecentsPresenter(
|
|||||||
pairs.filter { it.first.history.id == null && it.first.chapter.id != null }
|
pairs.filter { it.first.history.id == null && it.first.chapter.id != null }
|
||||||
.sortedWith(Comparator<Pair<MangaChapterHistory, Chapter>> { f1, f2 ->
|
.sortedWith(Comparator<Pair<MangaChapterHistory, Chapter>> { f1, f2 ->
|
||||||
if (abs(f1.second.date_fetch - f2.second.date_fetch) <=
|
if (abs(f1.second.date_fetch - f2.second.date_fetch) <=
|
||||||
TimeUnit.HOURS.toMillis(2))
|
TimeUnit.HOURS.toMillis(12))
|
||||||
f2.second.date_upload.compareTo(f1.second.date_upload)
|
f2.second.date_upload.compareTo(f1.second.date_upload)
|
||||||
else
|
else
|
||||||
f2.second.date_fetch.compareTo(f1.second.date_fetch)
|
f2.second.date_fetch.compareTo(f1.second.date_fetch)
|
||||||
@ -132,6 +133,13 @@ class RecentsPresenter(
|
|||||||
return chapters.sortedByDescending { it.source_order }.find { !it.read }
|
return chapters.sortedByDescending { it.source_order }.find { !it.read }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getFirstUpdatedChapter(manga: Manga, chapter: Chapter): Chapter? {
|
||||||
|
val chapters = db.getChapters(manga).executeAsBlocking()
|
||||||
|
return chapters.sortedByDescending { it.source_order }.find {
|
||||||
|
!it.read && abs(it.date_fetch - chapter.date_fetch) <= TimeUnit.HOURS.toMillis(12)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun onDestroy() {
|
fun onDestroy() {
|
||||||
downloadManager.removeListener(this)
|
downloadManager.removeListener(this)
|
||||||
LibraryUpdateService.removeListener(this)
|
LibraryUpdateService.removeListener(this)
|
||||||
|
Loading…
Reference in New Issue
Block a user