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] ## [Unreleased]
### Fixes
- Fix chapters cannot be opened from `Recents > Grouped` and `Recents > All`
## [1.9.0] ## [1.9.0]
### Additions ### Additions

View file

@ -179,7 +179,7 @@ class RecentsPresenter(
RecentsViewType.GroupedAll, RecentsViewType.UngroupedAll -> { RecentsViewType.GroupedAll, RecentsViewType.UngroupedAll -> {
getRecents.awaitAll( getRecents.awaitAll(
showRead, showRead,
true, false,
isEndless, isEndless,
!updatePageCount && !isOnFirstPage, !updatePageCount && !isOnFirstPage,
query, query,
@ -466,12 +466,14 @@ class RecentsPresenter(
} }
private suspend fun getNextChapter(manga: Manga): Chapter? { 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) return ChapterSort(manga, chapterFilter, preferences).getNextUnreadChapter(chapters, false)
} }
private suspend fun getFirstUpdatedChapter(manga: Manga, chapter: Chapter): Chapter? { 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 return chapters
.sortedWith(ChapterSort(manga, chapterFilter, preferences).sortComparator(true)).find { .sortedWith(ChapterSort(manga, chapterFilter, preferences).sortComparator(true)).find {
!it.read && abs(it.date_fetch - chapter.date_fetch) <= TimeUnit.HOURS.toMillis(12) !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; LIMIT :limit OFFSET :offset;
getRecentsAll: getRecentsAll:
SELECT R1.* FROM (
SELECT SELECT
M.*, M.*,
C.*, C.*,
@ -157,11 +156,9 @@ WHERE lower(title) LIKE '%' || :search || '%'
AND ( AND (
:apply_filter = 0 OR S.name IS NULL :apply_filter = 0 OR S.name IS NULL
) )
) AS R1
UNION -- Newly added chapter UNION -- Newly added chapter
SELECT R2.* FROM (
SELECT SELECT
M.*, M.*,
C.*, C.*,
@ -194,11 +191,9 @@ AND lower(title) LIKE '%' || :search || '%'
AND ( AND (
:apply_filter = 0 OR S.name IS NULL :apply_filter = 0 OR S.name IS NULL
) )
) AS R2
UNION -- Newly added manga UNION -- Newly added manga
SELECT R3.* FROM (
SELECT SELECT
M.*, M.*,
C.*, C.*,
@ -225,6 +220,6 @@ JOIN (
) AS C ) AS C
WHERE favorite = 1 WHERE favorite = 1
AND lower(title) LIKE '%' || :search || '%' AND lower(title) LIKE '%' || :search || '%'
) AS R3
ORDER BY history_last_read DESC ORDER BY history_last_read DESC
LIMIT :limit OFFSET :offset; LIMIT :limit OFFSET :offset;