Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit 139767a

Browse files
author
Leonardo Chaia
committed
fix: fixed registry settings subscriptions
1 parent 6122008 commit 139767a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/app/home/registry-cards/registry-cards.component.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, OnDestroy } from '@angular/core';
22
import { SettingsService } from '../../settings/settings.service';
33
import { TabService } from '../../tabs/tab.service';
44
import { TimoneerTabs } from '../../timoneer-tabs';
5+
import { Subject } from 'rxjs';
6+
import { takeUntil } from 'rxjs/operators';
57

68
@Component({
79
selector: 'tim-registry-cards',
810
templateUrl: './registry-cards.component.html',
911
styleUrls: ['./registry-cards.component.scss']
1012
})
11-
export class RegistryCardsComponent implements OnInit {
13+
export class RegistryCardsComponent implements OnInit, OnDestroy {
1214

1315
public loading: boolean;
1416

1517
public registries: { name: string, url: string }[];
18+
private componetDestroyed = new Subject();
1619

1720
constructor(private settingsService: SettingsService,
1821
private tabService: TabService) { }
1922

2023
public ngOnInit() {
2124

25+
this.registries = [];
2226
this.loading = true;
2327
this.settingsService.getSettings()
28+
.pipe(takeUntil(this.componetDestroyed))
2429
.subscribe(settings => {
2530
this.registries = settings.registries
2631
.filter(r => r.allowsCatalog)
@@ -42,4 +47,9 @@ export class RegistryCardsComponent implements OnInit {
4247
params: registry
4348
});
4449
}
50+
51+
public ngOnDestroy() {
52+
this.componetDestroyed.next();
53+
this.componetDestroyed.unsubscribe();
54+
}
4555
}

src/app/registry/registry.service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class RegistryService {
6565

6666
return this.settingsService.getRegistrySettingsForUrl(registryUrl)
6767
.pipe(
68+
take(1),
6869
switchMap(registrySettings => {
6970
if (!registrySettings) {
7071
return throwError(`Unauthorized, no registry settings found for registry [${registryUrl}]`);

0 commit comments

Comments
 (0)