From 02110962c13f5c021024c3345976a0556543677e Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Mon, 22 Apr 2024 14:29:08 +0800 Subject: [PATCH] fix: sync progress not compatible between Cantook and web reader Closes: #1477 --- komga-webui/src/functions/readium.ts | 7 ++- komga-webui/src/views/EpubReader.vue | 4 +- ...40422132621__fix_read_progress_locators.kt | 56 +++++++++++++++++++ .../komga/domain/service/BookLifecycle.kt | 1 - 4 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 komga/src/flyway/kotlin/db/migration/sqlite/V20240422132621__fix_read_progress_locators.kt diff --git a/komga-webui/src/functions/readium.ts b/komga-webui/src/functions/readium.ts index 041627cf..05955733 100644 --- a/komga-webui/src/functions/readium.ts +++ b/komga-webui/src/functions/readium.ts @@ -1,6 +1,7 @@ import {Locator, ReadingPosition} from '@d-i-t-a/reader' import {R2Location, R2Locator, R2Progression} from '@/types/readium' import {Locations} from '@d-i-t-a/reader/dist/types/model/Locator' +import urls from '@/functions/urls' export function createR2Progression(locator: Locator): R2Progression { return { @@ -15,7 +16,7 @@ export function createR2Progression(locator: Locator): R2Progression { function locatorToR2Locator(locator: Locator): R2Locator { return { - href: locator.href, + href: locator.href.startsWith(urls.originNoSlash) ? locator.href.replace(/(.*\/resource\/)/, '') : locator.href, type: locator.type || 'application/octet-stream', title: locator.title, locations: locationsToR2Location(locator.locations), @@ -32,11 +33,11 @@ function locationsToR2Location(location: Locations): R2Location { } } -export function r2ProgressionToReadingPosition(progression?: R2Progression): ReadingPosition | undefined { +export function r2ProgressionToReadingPosition(progression?: R2Progression, bookId: string): ReadingPosition | undefined { try { return { created: progression.modified, - href: progression.locator.href, + href: `${urls.originNoSlash}/api/v1/books/${bookId}/resource/${progression.locator.href}`, type: progression.locator.type, title: progression.locator.title, locations: { diff --git a/komga-webui/src/views/EpubReader.vue b/komga-webui/src/views/EpubReader.vue index d11a9416..847338ce 100644 --- a/komga-webui/src/views/EpubReader.vue +++ b/komga-webui/src/views/EpubReader.vue @@ -298,7 +298,7 @@