From 9f03c92bc1dc9a377bfef6eaa31fd871366bc108 Mon Sep 17 00:00:00 2001 From: Kazgatari <56477241+Kazgatari@users.noreply.github.com> Date: Mon, 6 Jul 2026 11:35:53 +0200 Subject: [PATCH] updated old code to remove warnings --- .../keywords-search.component.ts | 16 ++-- .../uni-trend-parent.component.ts | 81 +++++++++---------- 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/webapp/src/app/modules/keywords-search/keywords-search.component.ts b/webapp/src/app/modules/keywords-search/keywords-search.component.ts index 2697f79b..a4442326 100644 --- a/webapp/src/app/modules/keywords-search/keywords-search.component.ts +++ b/webapp/src/app/modules/keywords-search/keywords-search.component.ts @@ -75,6 +75,13 @@ type KeywordView = 'llm' | 'topic'; styleUrl: './keywords-search.component.scss', }) export class KeywordsSearchComponent { + private readonly formBuilder = inject(FormBuilder); + private readonly route = inject(ActivatedRoute); + private readonly router = inject(Router); + private readonly destroyRef = inject(DestroyRef); + private readonly websocketService = inject(KeywordWebSocketService); + private readonly topicsService = inject(TopicsService); + readonly form = this.formBuilder.nonNullable.group({ selectedInputType: 'url' as InputMode, urlInput: '', @@ -150,14 +157,7 @@ export class KeywordsSearchComponent { return buildTopicLegendGroups(topics); } - constructor( - private readonly formBuilder: FormBuilder, - private readonly route: ActivatedRoute, - private readonly router: Router, - private readonly destroyRef: DestroyRef, - private readonly websocketService: KeywordWebSocketService, - private readonly topicsService: TopicsService, - ) { + constructor() { this.route.queryParamMap.pipe(takeUntilDestroyed()).subscribe(() => { if (this.isOwnNavigation) { // This emission is just the router confirming the navigation we diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts index 7d38908b..2aa8650c 100644 --- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts +++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts @@ -43,7 +43,6 @@ export interface CompareItem { @Component({ selector: 'app-uni-trend-parent', - standalone: true, imports: [ CommonModule, FormsModule, @@ -195,55 +194,49 @@ export class UniTrendParentComponent implements OnInit { } // Effect: automatically sync checkboxes list whenever input keywords change - effect( - () => { - const kws = this.keywords(); - const currentSelections = untracked(() => this.selectedTrendTopics()); - const currentActive = untracked(() => this.activeChartTopic()); + effect(() => { + const kws = this.keywords(); + const currentSelections = untracked(() => this.selectedTrendTopics()); + const currentActive = untracked(() => this.activeChartTopic()); - if (kws.length > 0) { - // Find existing selections that are still in keywords, or default to all - const validSelections = currentSelections.filter((t: string) => - kws.includes(t), - ); - if (validSelections.length > 0) { - this.selectedTrendTopics.set(validSelections); - } else { - this.selectedTrendTopics.set(kws); - } - - // Initialize active chart topic to the first selected topic if empty or invalid - const active = currentActive; - const updatedSelections = untracked(() => this.selectedTrendTopics()); - if (!active || !updatedSelections.includes(active)) { - this.activeChartTopic.set(updatedSelections[0] || ''); - } - - // If comparison list is empty, initialize default institutions dynamically - const currentInsts = untracked(() => this.comparisonInstitutions()); - if (currentInsts.length === 0) { - untracked(() => this.initializeDefaultInstitutions()); - } + if (kws.length > 0) { + // Find existing selections that are still in keywords, or default to all + const validSelections = currentSelections.filter((t: string) => + kws.includes(t), + ); + if (validSelections.length > 0) { + this.selectedTrendTopics.set(validSelections); } else { - this.selectedTrendTopics.set([]); + this.selectedTrendTopics.set(kws); } - }, - { allowSignalWrites: true }, - ); + + // Initialize active chart topic to the first selected topic if empty or invalid + const active = currentActive; + const updatedSelections = untracked(() => this.selectedTrendTopics()); + if (!active || !updatedSelections.includes(active)) { + this.activeChartTopic.set(updatedSelections[0] || ''); + } + + // If comparison list is empty, initialize default institutions dynamically + const currentInsts = untracked(() => this.comparisonInstitutions()); + if (currentInsts.length === 0) { + untracked(() => this.initializeDefaultInstitutions()); + } + } else { + this.selectedTrendTopics.set([]); + } + }); // Effect: load suggestions when topic or location filters change - effect( - () => { - const topic = this.activeChartTopic(); - const countries = this.comparisonCountries(); - const regions = this.comparisonRegions(); + effect(() => { + const topic = this.activeChartTopic(); + const countries = this.comparisonCountries(); + const regions = this.comparisonRegions(); - untracked(() => { - this.loadTrendSuggestions(); - }); - }, - { allowSignalWrites: true }, - ); + untracked(() => { + this.loadTrendSuggestions(); + }); + }); // Handle initialization and synchronization of URL state this.route.queryParams.subscribe((params) => {