From b372efaada58bee068dca45dedb2780eb9aa6669 Mon Sep 17 00:00:00 2001 From: Joseph Milazzo Date: Sun, 8 Jun 2025 04:55:38 -0500 Subject: [PATCH] Fixed a bug where child actionables could have a bad click handler due to a shallow copy. Fixed missing localization strings. --- UI/Web/src/app/_services/action-factory.service.ts | 8 +++++++- .../bulk-set-reading-profile.component.ts | 7 +++---- UI/Web/src/assets/langs/en.json | 5 ++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/UI/Web/src/app/_services/action-factory.service.ts b/UI/Web/src/app/_services/action-factory.service.ts index 88d601165..e5967bf24 100644 --- a/UI/Web/src/app/_services/action-factory.service.ts +++ b/UI/Web/src/app/_services/action-factory.service.ts @@ -1117,7 +1117,10 @@ export class ActionFactoryService { if (action.children === null || action.children?.length === 0) return; - action.children?.forEach((childAction) => { + // Ensure action children are a copy of the parent (since parent does a shallow mapping) + action.children = action.children.map(d => { return {...d}; }); + + action.children.forEach((childAction) => { this.applyCallback(childAction, callback, shouldRenderFunc); }); } @@ -1125,10 +1128,13 @@ export class ActionFactoryService { public applyCallbackToList(list: Array>, callback: ActionCallback, shouldRenderFunc: ActionShouldRenderFunc = this.dummyShouldRender): Array> { + // Create a clone of the list to ensure we aren't affecting the default state const actions = list.map((a) => { return { ...a }; }); + actions.forEach((action) => this.applyCallback(action, callback, shouldRenderFunc)); + return actions; } diff --git a/UI/Web/src/app/cards/_modals/bulk-set-reading-profile/bulk-set-reading-profile.component.ts b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile/bulk-set-reading-profile.component.ts index ce0396947..54e98c527 100644 --- a/UI/Web/src/app/cards/_modals/bulk-set-reading-profile/bulk-set-reading-profile.component.ts +++ b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile/bulk-set-reading-profile.component.ts @@ -3,7 +3,6 @@ import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; import {ToastrService} from "ngx-toastr"; import {FormControl, FormGroup, ReactiveFormsModule} from "@angular/forms"; import {translate, TranslocoDirective} from "@jsverse/transloco"; -import {ReadingList} from "../../../_models/reading-list"; import {ReadingProfileService} from "../../../_services/reading-profile.service"; import {ReadingProfile} from "../../../_models/preferences/reading-profiles"; import {FilterPipe} from "../../../_pipes/filter.pipe"; @@ -66,7 +65,7 @@ export class BulkSetReadingProfileComponent implements OnInit, AfterViewInit { addToProfile(profile: ReadingProfile) { if (this.seriesIds.length == 1) { this.readingProfileService.addToSeries(profile.id, this.seriesIds[0]).subscribe(() => { - this.toastr.success(translate('toasts.series-added-to-reading-profile', {name: profile.name})); + this.toastr.success(translate('toasts.series-bound-to-reading-profile', {name: profile.name})); this.modal.close(); }); return; @@ -74,7 +73,7 @@ export class BulkSetReadingProfileComponent implements OnInit, AfterViewInit { if (this.seriesIds.length > 1) { this.readingProfileService.bulkAddToSeries(profile.id, this.seriesIds).subscribe(() => { - this.toastr.success(translate('toasts.series-added-to-reading-profile', {name: profile.name})); + this.toastr.success(translate('toasts.series-bound-to-reading-profile', {name: profile.name})); this.modal.close(); }); return; @@ -82,7 +81,7 @@ export class BulkSetReadingProfileComponent implements OnInit, AfterViewInit { if (this.libraryId) { this.readingProfileService.addToLibrary(profile.id, this.libraryId).subscribe(() => { - this.toastr.success(translate('toasts.library-added-to-reading-profile', {name: profile.name})); + this.toastr.success(translate('toasts.library-bound-to-reading-profile', {name: profile.name})); this.modal.close(); }); } diff --git a/UI/Web/src/assets/langs/en.json b/UI/Web/src/assets/langs/en.json index 7d10cae50..834c3ca02 100644 --- a/UI/Web/src/assets/langs/en.json +++ b/UI/Web/src/assets/langs/en.json @@ -2676,7 +2676,8 @@ "match-success": "Series matched correctly", "webtoon-override": "Switching to Webtoon mode due to images representing a webtoon.", "scrobble-gen-init": "Enqueued a job to generate scrobble events from past reading history and ratings, syncing them with connected services.", - "series-added-to-reading-profile": "Series added to Reading Profile {{name}}" + "series-bound-to-reading-profile": "Series bound to Reading Profile {{name}}", + "library-bound-to-reading-profile": "Library bound to Reading Profile {{name}}" }, "read-time-pipe": { @@ -2732,7 +2733,9 @@ "reading-profiles": "Reading Profiles", "set-reading-profile": "Set Reading Profile", + "set-reading-profile-tooltip": "Bind a Reading Profile to this Library", "clear-reading-profile": "Clear Reading Profile", + "clear-reading-profile-tooltip": "Clear Reading Profile for this Library", "cleared-profile": "Cleared Reading Profile", "others": "Others",