diff --git a/src/app/accounts/apiKey.component.ts b/src/app/accounts/apiKey.component.ts index 30faacee..b141de01 100644 --- a/src/app/accounts/apiKey.component.ts +++ b/src/app/accounts/apiKey.component.ts @@ -1,5 +1,6 @@ -import { Component, Input, ViewChild, ViewContainerRef } from "@angular/core"; +import { Component, Input, ViewChild, ViewContainerRef, OnDestroy } from "@angular/core"; import { Router } from "@angular/router"; +import { Subject, takeUntil } from "rxjs"; import { StateService } from "../../abstractions/state.service"; @@ -17,7 +18,7 @@ import { ApiLogInCredentials } from "@/jslib/common/src/models/domain/logInCrede selector: "app-apiKey", templateUrl: "apiKey.component.html", }) -export class ApiKeyComponent { +export class ApiKeyComponent implements OnDestroy { @ViewChild("environment", { read: ViewContainerRef, static: true }) environmentModal: ViewContainerRef; @Input() clientId = ""; @@ -27,6 +28,8 @@ export class ApiKeyComponent { successRoute = "/tabs/dashboard"; showSecret = false; + private destroyed$: Subject = new Subject(); + constructor( private authService: AuthService, private router: Router, @@ -92,12 +95,18 @@ export class ApiKeyComponent { this.environmentModal ); - childComponent.onSaved.subscribe(() => { + childComponent.onSaved.pipe(takeUntil(this.destroyed$)).subscribe(() => { modalRef.close(); }); } + toggleSecret() { this.showSecret = !this.showSecret; document.getElementById("client_secret").focus(); } + + ngOnDestroy(): void { + this.destroyed$.next(); + this.destroyed$.complete(); + } } diff --git a/src/app/main.ts b/src/app/main.ts index 985222bb..a4ef3140 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -1,13 +1,13 @@ import { enableProdMode } from "@angular/core"; import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; +import { AppModule } from "./app.module"; + import { isDev } from "@/jslib/electron/src/utils"; // tslint:disable-next-line require("../scss/styles.scss"); -import { AppModule } from "./app.module"; - if (!isDev()) { enableProdMode(); }