fix(epubreader): ignore progression without locator

Closes: #1352
This commit is contained in:
Gauthier Roebroeck 2023-12-18 10:58:32 +08:00
parent 4f79fbf0d2
commit d168c0a7ac
2 changed files with 20 additions and 16 deletions

View file

@ -32,18 +32,22 @@ function locationsToR2Location(location: Locations): R2Location {
}
}
export function r2ProgressionToReadingPosition(progression: R2Progression): ReadingPosition {
return {
created: progression.modified,
href: progression.locator.href,
type: progression.locator.type,
title: progression.locator.title,
locations: {
fragment: progression.locator.locations.fragment ? progression.locator.locations.fragment[0] : undefined,
position: progression.locator.locations.position,
progression: progression.locator.locations.progression,
totalProgression: progression.locator.locations.totalProgression,
},
text: progression.locator.text,
export function r2ProgressionToReadingPosition(progression?: R2Progression): ReadingPosition | undefined {
try {
return {
created: progression.modified,
href: progression.locator.href,
type: progression.locator.type,
title: progression.locator.title,
locations: {
fragment: progression.locator.locations.fragment ? progression.locator.locations.fragment[0] : undefined,
position: progression.locator.locations.position,
progression: progression.locator.locations.progression,
totalProgression: progression.locator.locations.totalProgression,
},
text: progression.locator.text,
}
} catch (e) {
return undefined
}
}

View file

@ -298,7 +298,7 @@
<script lang="ts">
import Vue from 'vue'
import D2Reader, {Locator} from '@d-i-t-a/reader'
import D2Reader, {Locator, ReadingPosition} from '@d-i-t-a/reader'
import {bookManifestUrl, bookPositionsUrl} from '@/functions/urls'
import {BookDto} from '@/types/komga-books'
import {getBookTitleCompact} from '@/functions/book-title'
@ -699,8 +699,8 @@ export default Vue.extend({
this.book = await this.$komgaBooks.getBook(bookId)
this.series = await this.$komgaSeries.getOneSeries(this.book.seriesId)
let initialLocation = await this.$komgaBooks.getProgression(bookId)
if (initialLocation) initialLocation = r2ProgressionToReadingPosition(initialLocation)
const progression = await this.$komgaBooks.getProgression(bookId)
const initialLocation = r2ProgressionToReadingPosition(progression)
// parse query params to get context and contextId
if (this.$route.query.contextId && this.$route.query.context