Remove unneeded code

This commit is contained in:
Amelia 2025-04-25 23:48:30 +02:00
parent 42a50b0551
commit 2487eb97e1
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
6 changed files with 11 additions and 44 deletions

View file

@ -35,7 +35,6 @@ export class ReviewCardComponent implements OnInit {
protected readonly ScrobbleProvider = ScrobbleProvider;
@Input({required: true}) review!: UserReview;
@Input() reviewLocation: 'series' | 'chapter' = 'series';
@Output() refresh = new EventEmitter<ReviewSeriesModalCloseEvent>();
isMyReview: boolean = false;
@ -60,10 +59,6 @@ export class ReviewCardComponent implements OnInit {
}
const ref = this.modalService.open(component, {size: 'lg', fullscreen: 'md'});
if (this.isMyReview) {
ref.componentInstance.reviewLocation = this.reviewLocation;
}
ref.componentInstance.review = this.review;
ref.closed.subscribe((res: ReviewSeriesModalCloseEvent | undefined) => {
if (res) {

View file

@ -39,7 +39,6 @@ export class ReviewModalComponent implements OnInit {
protected readonly minLength = 5;
@Input({required: true}) review!: UserReview;
@Input() reviewLocation: 'series' | 'chapter' = 'series';
reviewGroup!: FormGroup;
ngOnInit(): void {
@ -57,11 +56,10 @@ export class ReviewModalComponent implements OnInit {
if (!await this.confirmService.confirm(translate('toasts.delete-review'))) return;
let obs;
if (this.reviewLocation === 'series') {
if (!this.review.chapterId) {
obs = this.seriesService.deleteReview(this.review.seriesId);
}
if (this.reviewLocation === 'chapter') {
obs = this.chapterService.deleteChapterReview(this.review.chapterId!)
} else {
obs = this.chapterService.deleteChapterReview(this.review.chapterId)
}
obs?.subscribe(() => {
@ -77,11 +75,10 @@ export class ReviewModalComponent implements OnInit {
}
let obs;
if (this.reviewLocation === 'series') {
if (!this.review.chapterId) {
obs = this.seriesService.updateReview(this.review.seriesId, model.reviewBody);
}
if (this.reviewLocation === 'chapter') {
obs = this.chapterService.updateChapterReview(this.review.seriesId, this.review.chapterId!, model.reviewBody);
} else {
obs = this.chapterService.updateChapterReview(this.review.seriesId, this.review.chapterId, model.reviewBody);
}
obs?.subscribe(review => {

View file

@ -1,9 +1,9 @@
<div class="mb-3" *transloco="let t;prefix:'reviews'">
<app-carousel-reel [items]="userReviews" [alwaysShow]="true" [title]="t('user-reviews-local')"
[iconClasses]=iconClasses()
[clickableTitle]="canEditOrAdd()" (sectionClick)="openReviewModal()">
iconClasses="fa-solid fa-{{this.getUserReviews().length > 0 ? 'pen' : 'plus'}}"
[clickableTitle]=true (sectionClick)="openReviewModal()">
<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>
</app-carousel-reel>
</div>

View file

@ -34,8 +34,6 @@ export class ReviewsComponent {
@Input() volumeId: number | undefined;
@Input() chapter: Chapter | undefined;
@Input() reviewLocation: 'series' | 'chapter' = 'series';
user: User | undefined;
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() {
const userReview = this.getUserReviews();
const modalRef = this.modalService.open(ReviewModalComponent, DefaultModalOptions);
modalRef.componentInstance.reviewLocation = this.reviewLocation;
if (userReview.length > 0) {
modalRef.componentInstance.review = userReview[0];

View file

@ -183,8 +183,7 @@
<ng-template ngbNavContent>
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
[series]="series" [chapter]="chapter" [volumeId]="chapter.volumeId"
reviewLocation="chapter" />
[series]="series" [chapter]="chapter" [volumeId]="chapter.volumeId" />
}
</ng-template>
</li>

View file

@ -200,8 +200,7 @@
<ng-template ngbNavContent>
@defer (when activeTabId === TabID.Reviews; prefetch on idle) {
<app-reviews [userReviews]="userReviews" [plusReviews]="plusReviews"
[series]="series" [volumeId]="volumeId" [chapter]="volume.chapters[0]"
reviewLocation="chapter" />
[series]="series" [volumeId]="volumeId" [chapter]="volume.chapters[0]" />
}
</ng-template>
</li>