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:
parent
3eb494dff4
commit
218f642870
7 changed files with 281 additions and 59 deletions
|
|
@ -103,33 +103,8 @@ export class ReaderService {
|
|||
return this.httpClient.get<number>(this.baseUrl + 'reader/prev-chapter?seriesId=' + seriesId + '&volumeId=' + volumeId + '¤tChapterId=' + 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue