Skip to content

Commit

Permalink
NAS-131271 / 24.10.0 / Check for updates daily-button not working (by…
Browse files Browse the repository at this point in the history
… AlexKarpov98) (#10732)

* NAS-131271: Check for updates daily-button not working

(cherry picked from commit 69d3640)

* NAS-131271: PR Update

(cherry picked from commit b47d1f4)

* NAS-131271: PR update

(cherry picked from commit b633f67)

---------

Co-authored-by: Alex Karpov <[email protected]>
  • Loading branch information
bugclerk and AlexKarpov98 authored Sep 23, 2024
1 parent c208836 commit 503cd4d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('TrainCardComponent', () => {
selected: 'some train',
} as SystemUpdateTrains)),
trainValue$: new BehaviorSubject('train1'),
autoCheckValue$: new BehaviorSubject(false),
fullTrainList$: new BehaviorSubject(undefined),
selectedTrain$: new BehaviorSubject(undefined),
currentTrainDescription$: new BehaviorSubject<string>(''),
Expand Down Expand Up @@ -71,6 +70,6 @@ describe('TrainCardComponent', () => {
'Check for Updates Daily and Download if Available': true,
});

expect(spectator.inject(TrainService).toggleAutoCheck).toHaveBeenCalled();
expect(spectator.inject(TrainService).toggleAutoCheck).toHaveBeenCalledWith(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class TrainCardComponent implements OnInit {
this.trainService.getTrains(),
]).pipe(untilDestroyed(this)).subscribe({
next: ([isAutoDownloadOn, trains]) => {
this.trainService.autoCheckValue$.next(isAutoDownloadOn);
this.form.controls.auto_check.patchValue(isAutoDownloadOn);
this.checkable = true;
this.cdr.markForCheck();
this.trainService.fullTrainList$.next(trains.trains);
Expand Down Expand Up @@ -118,10 +118,6 @@ export class TrainCardComponent implements OnInit {
this.form.controls.train.patchValue(trainValue);
});

this.trainService.autoCheckValue$.pipe(untilDestroyed(this)).subscribe((autoCheckValue) => {
this.form.controls.auto_check.patchValue(autoCheckValue);
});

this.form.controls.train.valueChanges.pipe(pairwise(), untilDestroyed(this)).subscribe(([prevTrain, newTrain]) => {
this.trainService.onTrainChanged(newTrain, prevTrain);
});
Expand All @@ -130,7 +126,7 @@ export class TrainCardComponent implements OnInit {
filterAsync(() => this.authService.hasRole(Role.FullAdmin)),
untilDestroyed(this),
).subscribe(() => {
this.trainService.toggleAutoCheck();
this.trainService.toggleAutoCheck(this.form.controls.auto_check.value);
});
}
}
11 changes: 3 additions & 8 deletions src/app/pages/system/update/services/train.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import {
BehaviorSubject, Observable, combineLatest, filter, tap,
BehaviorSubject, Observable, combineLatest,
} from 'rxjs';
import { SystemUpdateOperationType, SystemUpdateStatus } from 'app/enums/system-update.enum';
import { SystemUpdateTrain, SystemUpdateTrains } from 'app/interfaces/system-update.interface';
Expand All @@ -28,7 +28,6 @@ export class TrainService {
trainVersion$ = new BehaviorSubject<string>(null);

trainValue$ = new BehaviorSubject<string>('');
autoCheckValue$ = new BehaviorSubject<boolean>(false);

constructor(
private updateService: UpdateService,
Expand Down Expand Up @@ -87,12 +86,8 @@ export class TrainService {
});
}

toggleAutoCheck(): void {
this.autoCheckValue$.pipe(
tap((autoCheckValue) => this.ws.call('update.set_auto_download', [autoCheckValue])),
filter(Boolean),
untilDestroyed(this),
).subscribe(() => {
toggleAutoCheck(autoCheck: boolean): void {
this.ws.call('update.set_auto_download', [autoCheck]).pipe(untilDestroyed(this)).subscribe(() => {
this.check();
});
}
Expand Down

0 comments on commit 503cd4d

Please sign in to comment.