Revert changes
This commit is contained in:
+2
-10
@@ -1,4 +1,4 @@
|
|||||||
import {Component, inject, Input, OnInit, OnChanges, SimpleChanges, ChangeDetectorRef} from '@angular/core';
|
import {Component, inject, Input, OnInit, OnChanges, SimpleChanges} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
import {ReadingSessionApiService, ReadingSessionResponse} from '../../../../../shared/service/reading-session-api.service';
|
||||||
import {TableModule} from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
@@ -16,7 +16,6 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
@Input() bookId!: number;
|
@Input() bookId!: number;
|
||||||
|
|
||||||
private readonly readingSessionService = inject(ReadingSessionApiService);
|
private readonly readingSessionService = inject(ReadingSessionApiService);
|
||||||
private readonly cdr = inject(ChangeDetectorRef);
|
|
||||||
|
|
||||||
sessions: ReadingSessionResponse[] = [];
|
sessions: ReadingSessionResponse[] = [];
|
||||||
totalRecords = 0;
|
totalRecords = 0;
|
||||||
@@ -25,7 +24,7 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// Rely on p-table onLazyLoad to trigger the initial load
|
this.loadSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
@@ -36,23 +35,16 @@ export class BookReadingSessionsComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSessions(page: number = 0) {
|
loadSessions(page: number = 0) {
|
||||||
// Prevent ExpressionChangedAfterItHasBeenCheckedError
|
|
||||||
setTimeout(() => {
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.cdr.markForCheck();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.readingSessionService.getSessionsByBookId(this.bookId, page, this.rows)
|
this.readingSessionService.getSessionsByBookId(this.bookId, page, this.rows)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
this.sessions = response.content;
|
this.sessions = response.content;
|
||||||
this.totalRecords = response.totalElements;
|
this.totalRecords = response.totalElements;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.cdr.markForCheck();
|
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.cdr.markForCheck();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,11 +257,6 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||||
const locations = this.book.locations.save();
|
const locations = this.book.locations.save();
|
||||||
|
|
||||||
if (this.rendition) {
|
|
||||||
this.rendition.destroy();
|
|
||||||
this.rendition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initBook(locations);
|
this.initBook(locations);
|
||||||
this.initRendition(cfi);
|
this.initRendition(cfi);
|
||||||
this.updateViewerSetting();
|
this.updateViewerSetting();
|
||||||
@@ -273,11 +268,6 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
const cfi = this.rendition.currentLocation()?.start?.cfi;
|
||||||
const locations = this.book.locations.save();
|
const locations = this.book.locations.save();
|
||||||
|
|
||||||
if (this.rendition) {
|
|
||||||
this.rendition.destroy();
|
|
||||||
this.rendition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.initBook(locations);
|
this.initBook(locations);
|
||||||
this.initRendition(cfi);
|
this.initRendition(cfi);
|
||||||
this.updateViewerSetting();
|
this.updateViewerSetting();
|
||||||
@@ -839,23 +829,7 @@ export class EpubReaderComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.off('keyup', this.keyListener);
|
this.rendition.off('keyup', this.keyListener);
|
||||||
try {
|
|
||||||
this.rendition.destroy();
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Error destroying rendition in ngOnDestroy', e);
|
|
||||||
}
|
}
|
||||||
this.rendition = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.book) {
|
|
||||||
try {
|
|
||||||
this.book.destroy();
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Error destroying book in ngOnDestroy', e);
|
|
||||||
}
|
|
||||||
this.book = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.removeEventListener('keyup', this.keyListener);
|
document.removeEventListener('keyup', this.keyListener);
|
||||||
|
|
||||||
if (this.hideControlsTimeout) {
|
if (this.hideControlsTimeout) {
|
||||||
|
|||||||
Reference in New Issue
Block a user