Fix: Respect excluded categories when manually marking chapters as read#3130
Open
leodyversemilla07 wants to merge 1 commit intomihonapp:mainfrom
Open
Fix: Respect excluded categories when manually marking chapters as read#3130leodyversemilla07 wants to merge 1 commit intomihonapp:mainfrom
leodyversemilla07 wants to merge 1 commit intomihonapp:mainfrom
Conversation
Fixes mihonapp#1521 The bug occurred because manual mark-as-read used stale in-memory chapter objects (with read=false) when checking exclusion filters, while the database had already been updated to read=true. This caused the exclusion filter to incorrectly identify read chapters as unread, allowing them to be deleted even in excluded categories. The fix refreshes chapter data from the database after marking as read, ensuring the exclusion filter sees the correct read=true status and properly protects chapters in excluded categories from deletion. Changes: - Fetch fresh chapter data from database before deletion - Ensures exclusion filter receives updated read status - Maintains consistency with automatic mark-as-read behavior Testing: - Manual mark as read now respects excluded categories - Automatic mark as read continues to work as before - Bookmarked chapter exclusion still works correctly
b276e2a to
f636062
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1521
Problem
When manually marking chapters as read via menu, the 'delete after marked as read' feature incorrectly deletes chapters even in excluded categories. This happens because:
read=falsechapters.filterNot { it.read }(only delete unread chapters to protect read ones)read=false, the filter thinks the chapter is unread and includes it for deletionRoot Cause
The deletion logic in
SetReadStatus.ktused in-memory chapter objects before they were refreshed from the database:chapterRepository.update(readUpdate)✅downloadManager.enqueueChaptersToDelete(chapters, manga)❌read=falseeven though database hasread=trueSolution
Refresh chapter data from database before deletion to ensure exclusion filters see the updated
read=truestatus:Comparison with Automatic Mark-as-Read
Automatic (after reading in ReaderViewModel) - works correctly:
getChaptersByMangaId(manga.id)✅Manual (via menu) - was broken:
This fix aligns manual behavior with the working automatic behavior.
Testing
Technical Details
Files Modified:
app/src/main/java/eu/kanade/domain/chapter/interactor/SetReadStatus.ktKey Methods:
DownloadManager.getChaptersToDelete()- contains exclusion filterDownloadManager.enqueueChaptersToDelete()- applies filters correctlyChapterRepository.getChapterById()- fetches fresh dataThe exclusion filter protects chapters in excluded categories by only deleting unread ones. With fresh data showing
read=true, these chapters are correctly excluded from deletion.