Refactored the setContinuePoint code from the UI to the backend. Now, through an API, we can get the chapter to restart from. (#973)

This commit is contained in:
Joseph Milazzo 2022-01-20 15:49:26 -08:00 committed by GitHub
parent 3eb494dff4
commit 218f642870
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 281 additions and 59 deletions

View file

@ -103,33 +103,8 @@ export class ReaderService {
return this.httpClient.get<number>(this.baseUrl + 'reader/prev-chapter?seriesId=' + seriesId + '&volumeId=' + volumeId + '&currentChapterId=' + currentChapterId);
}
getCurrentChapter(volumes: Array<Volume>): Chapter {
let currentlyReadingChapter: Chapter | undefined = undefined;
const chapters = volumes.filter(v => v.number !== 0).map(v => v.chapters || []).flat().sort(this.utilityService.sortChapters);
for (const c of chapters) {
if (c.pagesRead < c.pages) {
currentlyReadingChapter = c;
break;
}
}
if (currentlyReadingChapter === undefined) {
// Check if there are specials we can load:
const specials = volumes.filter(v => v.number === 0).map(v => v.chapters || []).flat().sort(this.utilityService.sortChapters);
for (const c of specials) {
if (c.pagesRead < c.pages) {
currentlyReadingChapter = c;
break;
}
}
if (currentlyReadingChapter === undefined) {
// Default to first chapter
currentlyReadingChapter = chapters[0];
}
}
return currentlyReadingChapter;
getCurrentChapter(seriesId: number) {
return this.httpClient.get<Chapter>(this.baseUrl + 'reader/continue-point?seriesId=' + seriesId);
}
/**