Feature: Sync reading progress from Kobo in-built reader (#1541)
* feat: add kobo reading progress sync * fix: remove old variable references * fix: avoid changing koreader behaviour * fix: resolve typo in koreader progress * fix: remove link between booklore progress and kobo sync progress * feat: add unit tests for kobo reading status sync * fix: remove unnecessary conversion value for kobo progress * fix: resolve issue with kobo_progress beiong optional in template * fix: update entitlement to provide existing reading progress back to kobo on sync * fix: use stored bookmark before creating new bookmark * fix: update default thresholds to full numbers. kobo doesn't report progress with any decimal places * chore: update unit tests * fix: remove decimal places in kobo settings progress threshold
This commit is contained in:
@@ -37,6 +37,7 @@ export interface Book extends FileInfo {
|
||||
pdfProgress?: PdfProgress;
|
||||
cbxProgress?: CbxProgress;
|
||||
koreaderProgress?: KoReaderProgress;
|
||||
koboProgress?: KoboProgress;
|
||||
seriesCount?: number | null;
|
||||
metadataMatchScore?: number | null;
|
||||
readStatus?: ReadStatus;
|
||||
@@ -65,6 +66,10 @@ export interface KoReaderProgress {
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface KoboProgress {
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
export interface BookMetadata {
|
||||
bookId: number;
|
||||
title?: string;
|
||||
|
||||
+22
@@ -364,6 +364,28 @@
|
||||
</span>
|
||||
</p>
|
||||
}
|
||||
@if (book?.koboProgress && book.koboProgress?.percentage != null) {
|
||||
<p class="whitespace-nowrap flex items-center">
|
||||
<span class="font-bold mr-2">Kobo Progress:</span>
|
||||
<span class="inline-flex items-center">
|
||||
<app-tag size="3xs" variant="pill" [color]="getKoProgressColor(book.koboProgress?.percentage)">
|
||||
{{ book.koboProgress?.percentage | number:'1.0-1' }}%
|
||||
</app-tag>
|
||||
@if (book.koboProgress?.percentage !== null) {
|
||||
<p-button
|
||||
pTooltip="Reset progress"
|
||||
tooltipPosition="bottom"
|
||||
icon="pi pi-refresh"
|
||||
size="small"
|
||||
severity="danger"
|
||||
text
|
||||
class="ml-1 custom-button-padding"
|
||||
(onClick)="resetProgress(book, ResetProgressTypes.KOBO)">
|
||||
</p-button>
|
||||
}
|
||||
</span>
|
||||
</p>
|
||||
}
|
||||
@if (selectedReadStatus === ReadStatus.READ) {
|
||||
<div>
|
||||
@if (book?.dateFinished) {
|
||||
|
||||
+48
@@ -100,6 +100,54 @@
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Reading at: {{ koboSyncSettings.progressMarkAsReadingThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsReadingThreshold"
|
||||
name="markAsReadingThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsReadingThreshold"
|
||||
[min]="1"
|
||||
[max]="10"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Reading" when progress exceeds this percentage. This helps automatically track which books you've started.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 1% (default) - marks as reading after the first page or two.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-info">
|
||||
<div class="setting-label-row">
|
||||
<label class="setting-label">Mark as Finished at: {{ koboSyncSettings.progressMarkAsFinishedThreshold?.toFixed(0) }}%</label>
|
||||
<div class="slider-container">
|
||||
<p-slider
|
||||
id="markAsFinishedThreshold"
|
||||
name="markAsFinishedThreshold"
|
||||
[(ngModel)]="koboSyncSettings.progressMarkAsFinishedThreshold"
|
||||
[min]="90"
|
||||
[max]="100"
|
||||
[step]="1"
|
||||
(ngModelChange)="onProgressThresholdsChange()">
|
||||
</p-slider>
|
||||
</div>
|
||||
</div>
|
||||
<p class="setting-description">
|
||||
Books are marked as "Finished" when progress reaches this percentage. Accounts for books where the last few pages are acknowledgments or index.
|
||||
<br>
|
||||
<strong>Recommended:</strong> 99% (default) - marks as finished when nearly complete.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
+27
-1
@@ -50,7 +50,9 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
|
||||
koboSyncSettings: KoboSyncSettings = {
|
||||
token: '',
|
||||
syncEnabled: false
|
||||
syncEnabled: false,
|
||||
progressMarkAsReadingThreshold: 1,
|
||||
progressMarkAsFinishedThreshold: 99
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -101,6 +103,8 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
next: (settings: KoboSyncSettings) => {
|
||||
this.koboSyncSettings.token = settings.token;
|
||||
this.koboSyncSettings.syncEnabled = settings.syncEnabled;
|
||||
this.koboSyncSettings.progressMarkAsReadingThreshold = settings.progressMarkAsReadingThreshold ?? 1;
|
||||
this.koboSyncSettings.progressMarkAsFinishedThreshold = settings.progressMarkAsFinishedThreshold ?? 99;
|
||||
this.credentialsSaved = !!settings.token;
|
||||
},
|
||||
error: () => {
|
||||
@@ -198,6 +202,28 @@ export class KoboSyncSettingsComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
onProgressThresholdsChange() {
|
||||
this.koboService.updateProgressThresholds(
|
||||
this.koboSyncSettings.progressMarkAsReadingThreshold,
|
||||
this.koboSyncSettings.progressMarkAsFinishedThreshold
|
||||
).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Thresholds Updated',
|
||||
detail: 'Progress thresholds updated successfully'
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to update progress thresholds'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveSettings() {
|
||||
this.settingsHelperService.saveSetting(AppSettingKey.KOBO_SETTINGS, this.koboSettings)
|
||||
.subscribe({
|
||||
|
||||
+13
@@ -6,6 +6,8 @@ import {API_CONFIG} from '../../../../../core/config/api-config';
|
||||
export interface KoboSyncSettings {
|
||||
token: string;
|
||||
syncEnabled: boolean;
|
||||
progressMarkAsReadingThreshold?: number;
|
||||
progressMarkAsFinishedThreshold?: number;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -27,4 +29,15 @@ export class KoboService {
|
||||
const params = new HttpParams().set('enabled', enabled.toString());
|
||||
return this.http.put<void>(`${this.baseUrl}/sync`, null, { params });
|
||||
}
|
||||
|
||||
updateProgressThresholds(readingThreshold?: number, finishedThreshold?: number): Observable<KoboSyncSettings> {
|
||||
let params = new HttpParams();
|
||||
if (readingThreshold !== undefined && readingThreshold !== null) {
|
||||
params = params.set('readingThreshold', readingThreshold.toString());
|
||||
}
|
||||
if (finishedThreshold !== undefined && finishedThreshold !== null) {
|
||||
params = params.set('finishedThreshold', finishedThreshold.toString());
|
||||
}
|
||||
return this.http.put<KoboSyncSettings>(`${this.baseUrl}/progress-thresholds`, null, { params });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user