fix(recents): Can't open chapters from Grouped and All

id column name for mangas and chapter is both _id causing it conflict when doing 'Rn.*'. In fact, 'Rn.*' is not even needed for union, it just needs to be on the same order, same type, and have the same number of columns.
This commit is contained in:
Ahmad Ansori Palembani 2024-12-09 21:57:17 +07:00
parent 22978ab8bf
commit d3c98fb897
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
3 changed files with 9 additions and 9 deletions

View file

@ -11,6 +11,9 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
## [Unreleased]
### Fixes
- Fix chapters cannot be opened from `Recents > Grouped` and `Recents > All`
## [1.9.0]
### Additions

View file

@ -179,7 +179,7 @@ class RecentsPresenter(
RecentsViewType.GroupedAll, RecentsViewType.UngroupedAll -> {
getRecents.awaitAll(
showRead,
true,
false,
isEndless,
!updatePageCount && !isOnFirstPage,
query,
@ -466,12 +466,14 @@ class RecentsPresenter(
}
private suspend fun getNextChapter(manga: Manga): Chapter? {
val chapters = getChapter.awaitAll(manga)
val mangaId = manga.id ?: return null
val chapters = getChapter.awaitAll(mangaId, true)
return ChapterSort(manga, chapterFilter, preferences).getNextUnreadChapter(chapters, false)
}
private suspend fun getFirstUpdatedChapter(manga: Manga, chapter: Chapter): Chapter? {
val chapters = getChapter.awaitAll(manga)
val mangaId = manga.id ?: return null
val chapters = getChapter.awaitAll(mangaId, true)
return chapters
.sortedWith(ChapterSort(manga, chapterFilter, preferences).sortComparator(true)).find {
!it.read && abs(it.date_fetch - chapter.date_fetch) <= TimeUnit.HOURS.toMillis(12)

View file

@ -110,7 +110,6 @@ ORDER BY max_last_read.history_last_read DESC
LIMIT :limit OFFSET :offset;
getRecentsAll:
SELECT R1.* FROM (
SELECT
M.*,
C.*,
@ -157,11 +156,9 @@ WHERE lower(title) LIKE '%' || :search || '%'
AND (
:apply_filter = 0 OR S.name IS NULL
)
) AS R1
UNION -- Newly added chapter
SELECT R2.* FROM (
SELECT
M.*,
C.*,
@ -194,11 +191,9 @@ AND lower(title) LIKE '%' || :search || '%'
AND (
:apply_filter = 0 OR S.name IS NULL
)
) AS R2
UNION -- Newly added manga
SELECT R3.* FROM (
SELECT
M.*,
C.*,
@ -225,6 +220,6 @@ JOIN (
) AS C
WHERE favorite = 1
AND lower(title) LIKE '%' || :search || '%'
) AS R3
ORDER BY history_last_read DESC
LIMIT :limit OFFSET :offset;