refactor(settings): replace unsubscribe logic with takeUntilDestroyed for better resource management (#443)

* refactor(settings): replace unsubscribe logic with takeUntilDestroyed for better resource management

* refactor(settings): streamline saveSettings method and improve error handling

* fix(settings): improve error handling in saveSetting method

* refactor(settings): update tab structure

* refactor(settings): implement OnDestroy interface and clean up unused destroyRef instances
This commit is contained in:
brios
2026-04-22 17:27:11 -04:00
committed by Zach Yale
parent 85e8d235b6
commit 7abac02b0c
25 changed files with 218 additions and 180 deletions
@@ -1,4 +1,5 @@
import {Component, inject, OnInit} from '@angular/core';
import {Component, DestroyRef, inject, OnInit} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
import {MessageService} from 'primeng/api';
import {MetadataMatchWeightsService} from '../../../../shared/service/metadata-match-weights.service';
@@ -39,6 +40,7 @@ export class MetadataMatchWeightsComponent implements OnInit {
private messageService = inject(MessageService);
private fb = inject(FormBuilder);
private t = inject(TranslocoService);
private destroyRef = inject(DestroyRef);
ngOnInit(): void {
this.form = this.fb.group({
@@ -95,7 +97,9 @@ export class MetadataMatchWeightsComponent implements OnInit {
}
];
this.appSettingsService.saveSettings(payload).subscribe({
this.appSettingsService.saveSettings(payload).pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
@@ -117,7 +121,9 @@ export class MetadataMatchWeightsComponent implements OnInit {
recalculate(): void {
this.isRecalculating = true;
this.weightsService.recalculateAll().subscribe({
this.weightsService.recalculateAll().pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe({
next: () => {
this.messageService.add({
severity: 'success',