Incognito Reader (#560)

* Hooked in incognito mode into the manga reader
This commit is contained in:
Joseph Milazzo 2021-09-07 05:45:17 -07:00 committed by GitHub
parent c728b79616
commit 2eaddbdfac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 103 additions and 13 deletions

View file

@ -7,7 +7,7 @@
</button>
<div>
<div style="font-weight: bold;">{{title}}</div>
<div style="font-weight: bold;">{{title}} <span *ngIf="incognitoMode">(<i class="fa fa-glasses" aria-hidden="true"></i><span class="sr-only">Incognito Mode</span>)</span></div>
<div class="subtitle">
{{subtitle}}
</div>

View file

@ -66,6 +66,11 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
volumeId!: number;
chapterId!: number;
/**
* If this is true, no progress will be saved.
*/
incognitoMode: boolean = false;
/**
* The current page. UI will show this number + 1.
*/
@ -259,6 +264,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
this.libraryId = parseInt(libraryId, 10);
this.seriesId = parseInt(seriesId, 10);
this.chapterId = parseInt(chapterId, 10);
this.incognitoMode = this.route.snapshot.queryParamMap.get('incognitoMode') === 'true';
this.continuousChaptersStack.push(this.chapterId);
@ -706,7 +712,10 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
this.continuousChaptersStack.push(chapterId);
// Load chapter Id onto route but don't reload
const lastSlashIndex = this.router.url.lastIndexOf('/');
const newRoute = this.router.url.substring(0, lastSlashIndex + 1) + this.chapterId + '';
let newRoute = this.router.url.substring(0, lastSlashIndex + 1) + this.chapterId + '';
if (this.incognitoMode) {
newRoute += '?incognitoMode=true';
}
window.history.replaceState({}, '', newRoute);
this.init();
} else {
@ -777,8 +786,9 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
pageNum = this.pageNum + 1;
}
this.readerService.saveProgress(this.seriesId, this.volumeId, this.chapterId, pageNum).pipe(take(1)).subscribe(() => {/* No operation */});
if (!this.incognitoMode) {
this.readerService.saveProgress(this.seriesId, this.volumeId, this.chapterId, pageNum).pipe(take(1)).subscribe(() => {/* No operation */});
}
this.isLoading = true;
this.canvasImage = this.cachedImages.current();
@ -929,6 +939,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
handleWebtoonPageChange(updatedPageNum: number) {
this.setPageNum(updatedPageNum);
if (this.incognitoMode) return;
this.readerService.saveProgress(this.seriesId, this.volumeId, this.chapterId, this.pageNum).pipe(take(1)).subscribe(() => {/* No operation */});
}