* Refactored the code for choosing the tab to select when updates occur or first load. Specials will no longer be auto-selected if present. We will always try to select Storyline.

* Fixed a bug where marking a chapter as unread was actually making it read

* When loading a book, put a spinner in the action bar

* Fixed an issue with last page not getting marked as read with epubs due to a bugfix from last release

* Removed some debug code
This commit is contained in:
Joseph Milazzo 2022-01-28 08:47:16 -08:00 committed by GitHub
parent 6fadbb5231
commit 868eb70506
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 50 deletions

View file

@ -33,6 +33,13 @@ import { ReaderService } from '../_services/reader.service';
import { SeriesService } from '../_services/series.service';
enum TabID {
Specials = 1,
Storyline = 2,
Volumes = 3,
Chapters = 4
}
@Component({
selector: 'app-series-detail',
templateUrl: './series-detail.component.html',
@ -61,7 +68,7 @@ export class SeriesDetailComponent implements OnInit, OnDestroy {
hasSpecials = false;
specials: Array<Chapter> = [];
activeTabId = 2;
activeTabId = TabID.Storyline;
hasNonSpecialVolumeChapters = false;
hasNonSpecialNonVolumeChapters = false;
@ -148,6 +155,10 @@ export class SeriesDetailComponent implements OnInit, OnDestroy {
return TagBadgeCursor;
}
get TabID(): typeof TabID {
return TabID;
}
constructor(private route: ActivatedRoute, private seriesService: SeriesService,
private router: Router, public bulkSelectionService: BulkSelectionService,
private modalService: NgbModal, public readerService: ReaderService,
@ -383,31 +394,7 @@ export class SeriesDetailComponent implements OnInit, OnDestroy {
});
}
// This shows Chapters/Issues tab
// If this has chapters that are not specials
if (this.chapters.filter(c => !c.isSpecial).length > 0) {
if (this.utilityService.formatChapterName(this.libraryType) == 'Book') {
this.activeTabId = 4;
}
this.hasNonSpecialNonVolumeChapters = true;
}
// This shows Volumes tab
if (this.volumes.filter(v => v.number !== 0).length !== 0) {
if (this.utilityService.formatChapterName(this.libraryType) == 'Book') {
this.activeTabId = 3;
}
this.hasNonSpecialVolumeChapters = true;
}
// If an update occured and we were on specials, re-activate Volumes/Chapters
if (!this.hasSpecials && !this.hasNonSpecialVolumeChapters && this.activeTabId != 2) {
this.activeTabId = 3;
}
if (this.hasSpecials) {
this.activeTabId = 1;
}
this.updateSelectedTab();
this.isLoading = false;
});
@ -416,6 +403,36 @@ export class SeriesDetailComponent implements OnInit, OnDestroy {
});
}
/**
* This will update the selected tab
*
* This assumes loadPage() has already primed all the calculations and state variables. Do not call directly.
*/
updateSelectedTab() {
// This shows Chapters/Issues tab
// If this has chapters that are not specials
if (this.chapters.filter(c => !c.isSpecial).length > 0) {
this.hasNonSpecialNonVolumeChapters = true;
}
// This shows Volumes tab
if (this.volumes.filter(v => v.number !== 0).length !== 0) {
this.hasNonSpecialVolumeChapters = true;
}
// If an update occured and we were on specials, re-activate Volumes/Chapters
if (!this.hasSpecials && !this.hasNonSpecialVolumeChapters && this.activeTabId != TabID.Storyline) {
this.activeTabId = TabID.Storyline;
}
if (this.hasNonSpecialVolumeChapters || this.hasNonSpecialNonVolumeChapters) {
this.activeTabId = TabID.Storyline;
} else {
this.activeTabId = TabID.Specials;
}
}
createHTML() {
this.userReview = (this.series.userReview === null ? '' : this.series.userReview).replace(/\n/g, '<br>');
}