Remove unneeded code
This commit is contained in:
parent
42a50b0551
commit
2487eb97e1
6 changed files with 11 additions and 44 deletions
|
|
@ -35,7 +35,6 @@ export class ReviewCardComponent implements OnInit {
|
||||||
protected readonly ScrobbleProvider = ScrobbleProvider;
|
protected readonly ScrobbleProvider = ScrobbleProvider;
|
||||||
|
|
||||||
@Input({required: true}) review!: UserReview;
|
@Input({required: true}) review!: UserReview;
|
||||||
@Input() reviewLocation: 'series' | 'chapter' = 'series';
|
|
||||||
@Output() refresh = new EventEmitter<ReviewSeriesModalCloseEvent>();
|
@Output() refresh = new EventEmitter<ReviewSeriesModalCloseEvent>();
|
||||||
|
|
||||||
isMyReview: boolean = false;
|
isMyReview: boolean = false;
|
||||||
|
|
@ -60,10 +59,6 @@ export class ReviewCardComponent implements OnInit {
|
||||||
}
|
}
|
||||||
const ref = this.modalService.open(component, {size: 'lg', fullscreen: 'md'});
|
const ref = this.modalService.open(component, {size: 'lg', fullscreen: 'md'});
|
||||||
|
|
||||||
if (this.isMyReview) {
|
|
||||||
ref.componentInstance.reviewLocation = this.reviewLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
ref.componentInstance.review = this.review;
|
ref.componentInstance.review = this.review;
|
||||||
ref.closed.subscribe((res: ReviewSeriesModalCloseEvent | undefined) => {
|
ref.closed.subscribe((res: ReviewSeriesModalCloseEvent | undefined) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ export class ReviewModalComponent implements OnInit {
|
||||||
protected readonly minLength = 5;
|
protected readonly minLength = 5;
|
||||||
|
|
||||||
@Input({required: true}) review!: UserReview;
|
@Input({required: true}) review!: UserReview;
|
||||||
@Input() reviewLocation: 'series' | 'chapter' = 'series';
|
|
||||||
reviewGroup!: FormGroup;
|
reviewGroup!: FormGroup;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
@ -57,11 +56,10 @@ export class ReviewModalComponent implements OnInit {
|
||||||
if (!await this.confirmService.confirm(translate('toasts.delete-review'))) return;
|
if (!await this.confirmService.confirm(translate('toasts.delete-review'))) return;
|
||||||
|
|
||||||
let obs;
|
let obs;
|
||||||
if (this.reviewLocation === 'series') {
|
if (!this.review.chapterId) {
|
||||||
obs = this.seriesService.deleteReview(this.review.seriesId);
|
obs = this.seriesService.deleteReview(this.review.seriesId);
|
||||||
}
|
} else {
|
||||||
if (this.reviewLocation === 'chapter') {
|
obs = this.chapterService.deleteChapterReview(this.review.chapterId)
|
||||||
obs = this.chapterService.deleteChapterReview(this.review.chapterId!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obs?.subscribe(() => {
|
obs?.subscribe(() => {
|
||||||
|
|
@ -77,11 +75,10 @@ export class ReviewModalComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
let obs;
|
let obs;
|
||||||
if (this.reviewLocation === 'series') {
|
if (!this.review.chapterId) {
|
||||||
obs = this.seriesService.updateReview(this.review.seriesId, model.reviewBody);
|
obs = this.seriesService.updateReview(this.review.seriesId, model.reviewBody);
|
||||||
}
|
} else {
|
||||||
if (this.reviewLocation === 'chapter') {
|
obs = this.chapterService.updateChapterReview(this.review.seriesId, this.review.chapterId, model.reviewBody);
|
||||||
obs = this.chapterService.updateChapterReview(this.review.seriesId, this.review.chapterId!, model.reviewBody);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obs?.subscribe(review => {
|
obs?.subscribe(review => {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<div class="mb-3" *transloco="let t;prefix:'reviews'">
|
<div class="mb-3" *transloco="let t;prefix:'reviews'">
|
||||||
<app-carousel-reel [items]="userReviews" [alwaysShow]="true" [title]="t('user-reviews-local')"
|
<app-carousel-reel [items]="userReviews" [alwaysShow]="true" [title]="t('user-reviews-local')"
|
||||||
[iconClasses]=iconClasses()
|
iconClasses="fa-solid fa-{{this.getUserReviews().length > 0 ? 'pen' : 'plus'}}"
|
||||||
[clickableTitle]="canEditOrAdd()" (sectionClick)="openReviewModal()">
|
[clickableTitle]=true (sectionClick)="openReviewModal()">
|
||||||
<ng-template #carouselItem let-item let-position="idx">
|
<ng-template #carouselItem let-item let-position="idx">
|
||||||
<app-review-card [reviewLocation]="reviewLocation" [review]="item" (refresh)="updateOrDeleteReview($event)"></app-review-card>
|
<app-review-card [review]="item" (refresh)="updateOrDeleteReview($event)"></app-review-card>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</app-carousel-reel>
|
</app-carousel-reel>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ export class ReviewsComponent {
|
||||||
@Input() volumeId: number | undefined;
|
@Input() volumeId: number | undefined;
|
||||||
@Input() chapter: Chapter | undefined;
|
@Input() chapter: Chapter | undefined;
|
||||||
|
|
||||||
@Input() reviewLocation: 'series' | 'chapter' = 'series';
|
|
||||||
|
|
||||||
user: User | undefined;
|
user: User | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -50,31 +48,10 @@ export class ReviewsComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
iconClasses(): string {
|
|
||||||
let classes = 'fa-solid';
|
|
||||||
if (this.canEditOrAdd()) {
|
|
||||||
classes += ' fa-' + (this.getUserReviews().length > 0 ? 'pen' : 'plus');
|
|
||||||
}
|
|
||||||
return classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
canEditOrAdd(): boolean {
|
|
||||||
if (this.reviewLocation === 'series') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.reviewLocation === 'chapter') {
|
|
||||||
return this.chapter !== undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
openReviewModal() {
|
openReviewModal() {
|
||||||
const userReview = this.getUserReviews();
|
const userReview = this.getUserReviews();
|
||||||
|
|
||||||
const modalRef = this.modalService.open(ReviewModalComponent, DefaultModalOptions);
|
const modalRef = this.modalService.open(ReviewModalComponent, DefaultModalOptions);
|
||||||
modalRef.componentInstance.reviewLocation = this.reviewLocation;
|
|
||||||
|
|
||||||
if (userReview.length > 0) {
|
if (userReview.length > 0) {
|
||||||
modalRef.componentInstance.review = userReview[0];
|
modalRef.componentInstance.review = userReview[0];
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,7 @@
|
||||||
<ng-template ngbNavContent>
|
<ng-template ngbNavContent>
|
||||||
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
|
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
|
||||||
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
|
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
|
||||||
[series]="series" [chapter]="chapter" [volumeId]="chapter.volumeId"
|
[series]="series" [chapter]="chapter" [volumeId]="chapter.volumeId" />
|
||||||
reviewLocation="chapter" />
|
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,7 @@
|
||||||
<ng-template ngbNavContent>
|
<ng-template ngbNavContent>
|
||||||
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
|
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
|
||||||
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
|
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
|
||||||
[series]="series" [volumeId]="volumeId" [chapter]="volume.chapters[0]"
|
[series]="series" [volumeId]="volumeId" [chapter]="volume.chapters[0]" />
|
||||||
reviewLocation="chapter" />
|
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue