Add bidirectional Kobo reading progress sync (#2791)
* Add bidirectional Kobo reading progress sync * Gate all two-way sync paths behind the toggle * Add comprehensive unit tests for Kobo services --------- Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
@@ -273,6 +273,8 @@ export class EbookReaderComponent implements OnInit, OnDestroy {
|
||||
// Navigate to saved position if progress exists, otherwise go to first page
|
||||
if (book.epubProgress?.cfi) {
|
||||
return this.viewManager.goTo(book.epubProgress.cfi);
|
||||
} else if (book.epubProgress?.percentage && book.epubProgress.percentage > 0) {
|
||||
return this.viewManager.goToFraction(book.epubProgress.percentage / 100);
|
||||
} else {
|
||||
return this.viewManager.goTo(0);
|
||||
}
|
||||
|
||||
+33
-26
@@ -49,16 +49,18 @@
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('kobo.autoAddLabel') }}</label>
|
||||
<label class="setting-label">{{ t('kobo.twoWaySyncLabel') }}</label>
|
||||
<p-toggle-switch
|
||||
id="autoAddToShelf"
|
||||
name="autoAddToShelf"
|
||||
[(ngModel)]="koboSyncSettings.autoAddToShelf"
|
||||
(ngModelChange)="onAutoAddToggle()">
|
||||
id="twoWayProgressSync"
|
||||
name="twoWayProgressSync"
|
||||
[(ngModel)]="koboSyncSettings.twoWayProgressSync"
|
||||
(ngModelChange)="onTwoWaySyncToggle()">
|
||||
</p-toggle-switch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('kobo.autoAddDesc') }}
|
||||
{{ t('kobo.twoWaySyncDesc') }}
|
||||
<br>
|
||||
<strong>{{ t('kobo.twoWaySyncNote') }}</strong>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,6 +97,14 @@
|
||||
(onClick)="toggleShowToken()"
|
||||
[disabled]="!koboSyncSettings.token">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
outlined="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
(onClick)="confirmRegenerateToken()"
|
||||
[disabled]="!credentialsSaved">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
@@ -103,26 +113,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('kobo.tokenManagement') }}</label>
|
||||
<p-button
|
||||
icon="pi pi-refresh"
|
||||
outlined="true"
|
||||
severity="warn"
|
||||
size="small"
|
||||
[label]="t('kobo.regenerateToken')"
|
||||
(onClick)="confirmRegenerateToken()"
|
||||
[disabled]="!credentialsSaved">
|
||||
</p-button>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('kobo.tokenManagementDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
@@ -170,6 +160,23 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">{{ t('kobo.autoAddLabel') }}</label>
|
||||
<p-toggle-switch
|
||||
id="autoAddToShelf"
|
||||
name="autoAddToShelf"
|
||||
[(ngModel)]="koboSyncSettings.autoAddToShelf"
|
||||
(ngModelChange)="onAutoAddToggle()">
|
||||
</p-toggle-switch>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
{{ t('kobo.autoAddDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+10
-1
@@ -60,7 +60,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
syncEnabled: false,
|
||||
progressMarkAsReadingThreshold: 1,
|
||||
progressMarkAsFinishedThreshold: 99,
|
||||
autoAddToShelf: true
|
||||
autoAddToShelf: true,
|
||||
twoWayProgressSync: false
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -121,6 +122,7 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
this.koboSyncSettings.progressMarkAsReadingThreshold = settings.progressMarkAsReadingThreshold ?? 1;
|
||||
this.koboSyncSettings.progressMarkAsFinishedThreshold = settings.progressMarkAsFinishedThreshold ?? 99;
|
||||
this.koboSyncSettings.autoAddToShelf = settings.autoAddToShelf ?? false;
|
||||
this.koboSyncSettings.twoWayProgressSync = settings.twoWayProgressSync ?? false;
|
||||
this.credentialsSaved = !!settings.token;
|
||||
},
|
||||
error: () => {
|
||||
@@ -227,6 +229,13 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
this.updateKoboSettings(message);
|
||||
}
|
||||
|
||||
onTwoWaySyncToggle() {
|
||||
const message = this.koboSyncSettings.twoWayProgressSync
|
||||
? this.t.translate('settingsDevice.kobo.twoWaySyncEnabled')
|
||||
: this.t.translate('settingsDevice.kobo.twoWaySyncDisabled');
|
||||
this.updateKoboSettings(message);
|
||||
}
|
||||
|
||||
private updateKoboSettings(successMessage: string) {
|
||||
this.koboService.updateSettings(this.koboSyncSettings).subscribe({
|
||||
next: () => {
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ export interface KoboSyncSettings {
|
||||
progressMarkAsReadingThreshold?: number;
|
||||
progressMarkAsFinishedThreshold?: number;
|
||||
autoAddToShelf: boolean;
|
||||
twoWayProgressSync: boolean;
|
||||
hardcoverApiKey?: string;
|
||||
hardcoverSyncEnabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,11 @@
|
||||
"syncEnabled": "Kobo sync enabled",
|
||||
"syncDisabled": "Kobo sync disabled",
|
||||
"progressUpdated": "Progress thresholds updated successfully",
|
||||
"twoWaySyncLabel": "Two-Way Reading Progress Sync",
|
||||
"twoWaySyncDesc": "Enable bidirectional sync between Booklore's web reader and your Kobo device. Reading progress made on either platform will be reflected on the other.",
|
||||
"twoWaySyncNote": "Note: Due to different position formats, sync accuracy is best-effort. In most cases progress will be accurate to the chapter level.",
|
||||
"twoWaySyncEnabled": "Two-way progress sync enabled",
|
||||
"twoWaySyncDisabled": "Two-way progress sync disabled",
|
||||
"autoAddEnabled": "New books will be automatically added to Kobo shelf",
|
||||
"autoAddDisabled": "Auto-add to Kobo shelf disabled",
|
||||
"pros": "Pros:",
|
||||
|
||||
@@ -94,6 +94,11 @@
|
||||
"syncEnabled": "Sincronización Kobo habilitada",
|
||||
"syncDisabled": "Sincronización Kobo deshabilitada",
|
||||
"progressUpdated": "Umbrales de progreso actualizados correctamente",
|
||||
"twoWaySyncLabel": "Sincronización bidireccional del progreso de lectura",
|
||||
"twoWaySyncDesc": "Habilita la sincronización bidireccional entre el lector web de Booklore y tu dispositivo Kobo. El progreso de lectura realizado en cualquiera de las plataformas se reflejará en la otra.",
|
||||
"twoWaySyncNote": "Nota: Debido a los diferentes formatos de posición, la precisión de la sincronización es aproximada. En la mayoría de los casos, el progreso será preciso a nivel de capítulo.",
|
||||
"twoWaySyncEnabled": "Sincronización bidireccional de progreso habilitada",
|
||||
"twoWaySyncDisabled": "Sincronización bidireccional de progreso deshabilitada",
|
||||
"autoAddEnabled": "Los libros nuevos se añadirán automáticamente al estante Kobo",
|
||||
"autoAddDisabled": "Auto-añadir al estante Kobo deshabilitado",
|
||||
"pros": "Ventajas:",
|
||||
|
||||
Reference in New Issue
Block a user