[PR #5120] Update onlyShowLaterBooksInContinueSeries to account for rereads #4435

Open
opened 2026-04-25 00:19:44 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/5120
Author: @octopotato
Created: 3/12/2026
Status: 🔄 Open

Base: masterHead: fix/continue-series-reread


📝 Commits (1)

  • 953dddb Fix continue-series to use most recently finished book when onlyShowLaterBooks is enabled

📊 Changes

2 files changed (+233 additions, -10 deletions)

View changed files

📝 server/utils/queries/libraryItemsBookFilters.js (+13 -10)
test/server/utils/queries/libraryItemsBookFilters.test.js (+220 -0)

📄 Description

Brief summary

I updated the onlyShowLaterBooksInContinueSeries query to use the most recently finished book's position instead of the highest finished sequence. This makes rereads actually move your continue-series position.

Which issue is fixed?

I was going to open an issue but found #2687, where this was originally introduced, where it was called out that "this would not really help re-listeners." Figured I'd take a crack at that. Happy to open a separate/new issue for it.

In-depth Description

The max(sequence) approach only ever goes forward, so rereading an earlier book has no effect on where continue-series picks up. If you finished books 1-5 and reread book 1, it still shows book 6.

I switched the subquery to order by finishedAt (with COALESCE to updatedAt for older records that might not have it) and grab the first result. So re-finishing book 1 gives you sequence 1, next book shown is 2.

For batch mark-as-finished where everything gets the same finishedAt, I added a sequence tiebreaker so it falls back to the highest sequence, basically the same as the old behavior.

I also had to widen the bookSeries include to not filter out finished books when the setting is on, since after a reread the "next" book might be one you've already read.

Default behavior (setting off) is untouched.

Not 100% sure if this should live behind a separate setting or if changing the existing one is fine. Happy to split it out if that's preferred.

How have you tested this?

Ran the server locally with the setting enabled and confirmed the reread scenario shows the right book. Also added integration tests.

Screenshots

https://github.com/user-attachments/assets/a9b03394-0b98-49e5-9310-2ad617b57b77


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/5120 **Author:** [@octopotato](https://github.com/octopotato) **Created:** 3/12/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/continue-series-reread` --- ### 📝 Commits (1) - [`953dddb`](https://github.com/advplyr/audiobookshelf/commit/953dddbbd737e8b374e7794e0a16fc6f8915fe33) Fix continue-series to use most recently finished book when onlyShowLaterBooks is enabled ### 📊 Changes **2 files changed** (+233 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/queries/libraryItemsBookFilters.js` (+13 -10) ➕ `test/server/utils/queries/libraryItemsBookFilters.test.js` (+220 -0) </details> ### 📄 Description ## Brief summary I updated the `onlyShowLaterBooksInContinueSeries` query to use the most recently finished book's position instead of the highest finished sequence. This makes rereads actually move your continue-series position. ## Which issue is fixed? I was going to open an issue but found #2687, where this was originally introduced, where it was called out that "this would not really help re-listeners." Figured I'd take a crack at that. Happy to open a separate/new issue for it. ## In-depth Description The `max(sequence)` approach only ever goes forward, so rereading an earlier book has no effect on where continue-series picks up. If you finished books 1-5 and reread book 1, it still shows book 6. I switched the subquery to order by `finishedAt` (with `COALESCE` to `updatedAt` for older records that might not have it) and grab the first result. So re-finishing book 1 gives you sequence 1, next book shown is 2. For batch mark-as-finished where everything gets the same `finishedAt`, I added a sequence tiebreaker so it falls back to the highest sequence, basically the same as the old behavior. I also had to widen the `bookSeries` include to not filter out finished books when the setting is on, since after a reread the "next" book might be one you've already read. Default behavior (setting off) is untouched. Not 100% sure if this should live behind a separate setting or if changing the existing one is fine. Happy to split it out if that's preferred. ## How have you tested this? Ran the server locally with the setting enabled and confirmed the reread scenario shows the right book. Also added integration tests. ## Screenshots https://github.com/user-attachments/assets/a9b03394-0b98-49e5-9310-2ad617b57b77 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:44 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4435