Skip to content

Commit

Permalink
Stop requests when not needed (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Senyoret1 authored Apr 27, 2023
1 parent f3a00c2 commit 42daad4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { InitialSetupComponent } from './initial-setup/initial-setup.component';
import { OperationError } from '../../../utils/operation-error';
import { processServiceError } from '../../../utils/errors';
import { AppComponent } from 'src/app/app.component';
import { MultipleNodeDataService } from 'src/app/services/multiple-node-data.service';

/**
* Login page.
Expand All @@ -36,9 +37,13 @@ export class LoginComponent implements OnInit, OnDestroy {
private snackbarService: SnackbarService,
private dialog: MatDialog,
private route: ActivatedRoute,
private multipleNodeDataService: MultipleNodeDataService,
) { }

ngOnInit() {
// Stop multiple requests that will fail for auth.
this.multipleNodeDataService.stopRequestingData();

this.routeSubscription = this.route.paramMap.subscribe(params => {
this.vpnKey = params.get('key');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export class MultipleNodeDataService {
return this.dataSubject.asObservable();
}

/**
* Makes the service stop returning the node list.
*/
stopRequestingData() {
if (this.updateSubscription) {
this.updateSubscription.unsubscribe();
this.firstCallToGetDataMade = false;
}
}

/**
* Starts periodically getting the node list.
* @param delayMs Delay before loading the data.
Expand Down

0 comments on commit 42daad4

Please sign in to comment.