-
-
Notifications
You must be signed in to change notification settings - Fork 39
feat: show audiobooks under all their series and fix the Primary-series toggle (#658) #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
therobbiedavis
merged 4 commits into
Listenarrs:canary
from
s3ntin3l8:658-multi-series-display-and-primary-toggle
Jun 9, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ba93890
feat: show audiobooks under all their series; fix Primary-series togg…
s3ntin3l8 893e418
fix: address PR #659 review feedback
s3ntin3l8 d441e09
fix: series catalog uses the viewed series' position for not-added books
s3ntin3l8 16f828c
refactor: rename misleading series-membership repo method
s3ntin3l8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { formatSeriesMemberships } from '@/utils/seriesUtils' | ||
|
|
||
| describe('formatSeriesMemberships', () => { | ||
| it('lists every series a book belongs to with its number', () => { | ||
| const result = formatSeriesMemberships({ | ||
| series: 'Publication Order', | ||
| seriesNumber: '1', | ||
| seriesMemberships: [ | ||
| { seriesName: 'Publication Order', seriesNumber: '1', isPrimary: true, sortOrder: 0 }, | ||
| { seriesName: 'Chronological Order', seriesNumber: '3', isPrimary: false, sortOrder: 1 }, | ||
| ], | ||
| }) | ||
| expect(result).toBe('Publication Order #1, Chronological Order #3') | ||
| }) | ||
|
|
||
| it('omits the number when a membership has none', () => { | ||
| const result = formatSeriesMemberships({ | ||
| seriesMemberships: [{ seriesName: 'Standalone Saga', isPrimary: true, sortOrder: 0 }], | ||
| }) | ||
| expect(result).toBe('Standalone Saga') | ||
| }) | ||
|
|
||
| it('falls back to the legacy single series when there are no memberships', () => { | ||
| expect(formatSeriesMemberships({ series: 'Solo Series', seriesNumber: '2' })).toBe( | ||
| 'Solo Series #2', | ||
| ) | ||
| expect(formatSeriesMemberships({ series: 'No Number' })).toBe('No Number') | ||
| }) | ||
|
|
||
| it('returns an empty string when there is no series information', () => { | ||
| expect(formatSeriesMemberships({})).toBe('') | ||
| expect(formatSeriesMemberships({ seriesMemberships: [] })).toBe('') | ||
| }) | ||
| }) |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Listenarr - Audiobook Management System | ||
| * Copyright (C) 2024-2026 Listenarr Contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published | ||
| * by the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
| import type { Audiobook, AudiobookSeriesMembership } from '@/types' | ||
|
|
||
| type SeriesBearer = Pick<Audiobook, 'series' | 'seriesNumber' | 'seriesMemberships'> | ||
|
|
||
| /** | ||
| * All series a book belongs to, formatted for display (e.g. "Publication Order #1, | ||
| * Chronological Order #3"). Uses every series membership so a multi-series book shows all of | ||
| * them; falls back to the legacy single series/number when no memberships are present. | ||
| */ | ||
| export function formatSeriesMemberships(book: SeriesBearer): string { | ||
| const memberships = book.seriesMemberships | ||
| if (memberships && memberships.length > 0) { | ||
| const parts = memberships.map(formatMembership).filter(Boolean) | ||
| if (parts.length > 0) return parts.join(', ') | ||
| } | ||
|
|
||
| const legacyName = (book.series || '').trim() | ||
| if (!legacyName) return '' | ||
| const legacyNumber = (book.seriesNumber || '').trim() | ||
| return legacyNumber ? `${legacyName} #${legacyNumber}` : legacyName | ||
| } | ||
|
|
||
| function formatMembership(membership: AudiobookSeriesMembership): string { | ||
| const name = (membership.seriesName || '').trim() | ||
| if (!name) return '' | ||
| const number = (membership.seriesNumber || '').trim() | ||
| return number ? `${name} #${number}` : name | ||
| } |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.