mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
97cd03325f
Scanned books are commonly distributed as DjVu, which the scanner only stored as a supplement. Decode pages on the server with DjVuLibre so DjVu imports with a cover and page count, opens in the image reader with its embedded OCR text, and can be the preferred format of an ordinary email recipient. Migration 0113 widens the recipient format check to allow it. Decoding runs on validated private snapshots behind a bounded, reader-first queue, and revalidation and cached pages are answered without a decoder. Released iOS builds cannot open DjVu, so series continuation offers it only to callers sending includeDjvu=true, and the dashboard and notebook read file never name it. The first full scan after upgrading promotes stored .djvu supplements to content.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { ref } from 'vue'
|
|
import type { ReaderFormatGroup, SeriesNextBook, SeriesNextBookResponse } from '@bookorbit/types'
|
|
import { api } from '@/lib/api'
|
|
|
|
/**
|
|
* The next book of a series that this reader can open, resolved server-side so a long series is
|
|
* never paged through on the client. A book outside any series, or one at the end, yields null.
|
|
*/
|
|
export function useSeriesNextBook(formatGroup: ReaderFormatGroup) {
|
|
const nextBook = ref<SeriesNextBook | null>(null)
|
|
|
|
// Nothing here is worth interrupting the reader for: without an answer the reader simply ends
|
|
// at the last page, the way it did before there was a handoff.
|
|
async function load(seriesId: number | null, bookId: number): Promise<void> {
|
|
nextBook.value = null
|
|
if (seriesId === null) return
|
|
|
|
try {
|
|
const res = await api(`/api/v1/series/${seriesId}/books/${bookId}/next?formatGroup=${formatGroup}&includeDjvu=true`)
|
|
if (!res.ok) return
|
|
|
|
const data = (await res.json()) as SeriesNextBookResponse
|
|
nextBook.value = data.next ?? null
|
|
} catch {
|
|
nextBook.value = null
|
|
}
|
|
}
|
|
|
|
return { nextBook, load }
|
|
}
|