From 2487eb97e19b09a55d15bb185828ecb16cf717cf Mon Sep 17 00:00:00 2001 From: Amelia <77553571+Fesaa@users.noreply.github.com> Date: Fri, 25 Apr 2025 23:48:30 +0200 Subject: [PATCH] Remove unneeded code --- .../review-card/review-card.component.ts | 5 ---- .../review-modal/review-modal.component.ts | 15 +++++------- .../reviews/reviews.component.html | 6 ++--- .../reviews/reviews.component.ts | 23 ------------------- .../chapter-detail.component.html | 3 +-- .../volume-detail.component.html | 3 +-- 6 files changed, 11 insertions(+), 44 deletions(-) diff --git a/UI/Web/src/app/_single-module/review-card/review-card.component.ts b/UI/Web/src/app/_single-module/review-card/review-card.component.ts index f609248fa..b628ffe94 100644 --- a/UI/Web/src/app/_single-module/review-card/review-card.component.ts +++ b/UI/Web/src/app/_single-module/review-card/review-card.component.ts @@ -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(); 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) { diff --git a/UI/Web/src/app/_single-module/review-modal/review-modal.component.ts b/UI/Web/src/app/_single-module/review-modal/review-modal.component.ts index 26b9c087c..cea38ffa4 100644 --- a/UI/Web/src/app/_single-module/review-modal/review-modal.component.ts +++ b/UI/Web/src/app/_single-module/review-modal/review-modal.component.ts @@ -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 => { diff --git a/UI/Web/src/app/_single-module/reviews/reviews.component.html b/UI/Web/src/app/_single-module/reviews/reviews.component.html index add498ab9..6a8c5c3af 100644 --- a/UI/Web/src/app/_single-module/reviews/reviews.component.html +++ b/UI/Web/src/app/_single-module/reviews/reviews.component.html @@ -1,9 +1,9 @@
+ iconClasses="fa-solid fa-{{this.getUserReviews().length > 0 ? 'pen' : 'plus'}}" + [clickableTitle]=true (sectionClick)="openReviewModal()"> - +
diff --git a/UI/Web/src/app/_single-module/reviews/reviews.component.ts b/UI/Web/src/app/_single-module/reviews/reviews.component.ts index 9a7ae246c..89de77b84 100644 --- a/UI/Web/src/app/_single-module/reviews/reviews.component.ts +++ b/UI/Web/src/app/_single-module/reviews/reviews.component.ts @@ -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]; diff --git a/UI/Web/src/app/chapter-detail/chapter-detail.component.html b/UI/Web/src/app/chapter-detail/chapter-detail.component.html index 338055465..795e20e53 100644 --- a/UI/Web/src/app/chapter-detail/chapter-detail.component.html +++ b/UI/Web/src/app/chapter-detail/chapter-detail.component.html @@ -183,8 +183,7 @@ @defer (when activeTabId === TabID.Reviews; prefetch on idle) { + [series]="series" [chapter]="chapter" [volumeId]="chapter.volumeId" /> } diff --git a/UI/Web/src/app/volume-detail/volume-detail.component.html b/UI/Web/src/app/volume-detail/volume-detail.component.html index 8cbfee5d8..3463307a1 100644 --- a/UI/Web/src/app/volume-detail/volume-detail.component.html +++ b/UI/Web/src/app/volume-detail/volume-detail.component.html @@ -200,8 +200,7 @@ @defer (when activeTabId === TabID.Reviews; prefetch on idle) { + [series]="series" [volumeId]="volumeId" [chapter]="volume.chapters[0]" /> }