mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
feat(books): show read-along chapters and hide audiobook request
An EPUB with Media Overlays already carries its narration, yet the Chapters tab required audio files and the Editions panel offered to request an audiobook the book already had. List the narration sections of such an EPUB as a read-only chapter list, and count the narration as the audio half when deciding which format is missing. The chapters state gains an optional readAlong flag, so released clients keep working. Editing stays tied to audio files, because an EPUB has no chapter metadata to write. Ref #2032
This commit is contained in:
@@ -2,6 +2,7 @@ import { computed, ref, watch, type Ref } from 'vue'
|
||||
import { BOOK_REQUEST_FORMATS_BY_MEDIA_KIND } from '@bookorbit/types'
|
||||
import type { BookDetail, BookRequestAvailability, BookRequestMediaKind, BookRequestSubmitResult, CreateBookRequestPayload } from '@bookorbit/types'
|
||||
import { api } from '@/lib/api'
|
||||
import { hasReadAlong } from '@/features/book/lib/file-capabilities'
|
||||
import { pairHalfState, type PairHalfState } from '../requestPair'
|
||||
import { submitFailure, type SubmitFailure } from './useRequestSubmission'
|
||||
|
||||
@@ -23,11 +24,11 @@ export function useMissingFormatRequest(book: Ref<BookDetail | null>, enabled: R
|
||||
|
||||
const missing = computed<BookRequestMediaKind | null>(() => {
|
||||
if (!book.value) return null
|
||||
const formats = book.value.files
|
||||
.filter((file) => file.role === 'content' || file.role === 'primary')
|
||||
.map((file) => file.format?.toLowerCase() ?? '')
|
||||
const files = book.value.files.filter((file) => file.role === 'content' || file.role === 'primary')
|
||||
const formats = files.map((file) => file.format?.toLowerCase() ?? '')
|
||||
const hasReadable = formats.some((format) => BOOK_REQUEST_FORMATS_BY_MEDIA_KIND.ebook.includes(format))
|
||||
const hasAudio = formats.some((format) => BOOK_REQUEST_FORMATS_BY_MEDIA_KIND.audiobook.includes(format))
|
||||
// A read-along EPUB carries its narration, so the book already has the audio half.
|
||||
const hasAudio = formats.some((format) => BOOK_REQUEST_FORMATS_BY_MEDIA_KIND.audiobook.includes(format)) || files.some(hasReadAlong)
|
||||
if (hasReadable && !hasAudio) return 'audiobook'
|
||||
if (hasAudio && !hasReadable) return 'ebook'
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user