From 623cda8b64a50a2c639201c6336ebedf0ac4948d Mon Sep 17 00:00:00 2001 From: rr-bw <102181210+rr-bw@users.noreply.github.com> Date: Wed, 22 May 2024 07:48:05 -0700 Subject: [PATCH] fix DI (#9294) --- .../src/components/import.component.ts | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/libs/importer/src/components/import.component.ts b/libs/importer/src/components/import.component.ts index 13a09304f4..a140624870 100644 --- a/libs/importer/src/components/import.component.ts +++ b/libs/importer/src/components/import.component.ts @@ -16,6 +16,8 @@ import { concat, Observable, Subject, lastValueFrom, combineLatest, firstValueFr import { filter, map, takeUntil } from "rxjs/operators"; import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { safeProvider, SafeProvider } from "@bitwarden/angular/platform/utils/safe-provider"; +import { PinServiceAbstraction } from "@bitwarden/auth/common"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { canAccessImport, @@ -64,6 +66,27 @@ import { } from "./dialog"; import { ImportLastPassComponent } from "./lastpass"; +const safeProviders: SafeProvider[] = [ + safeProvider({ + provide: ImportApiServiceAbstraction, + useClass: ImportApiService, + deps: [ApiService], + }), + safeProvider({ + provide: ImportServiceAbstraction, + useClass: ImportService, + deps: [ + CipherService, + FolderService, + ImportApiServiceAbstraction, + I18nService, + CollectionService, + CryptoService, + PinServiceAbstraction, + ], + }), +]; + @Component({ selector: "tools-import", templateUrl: "import.component.html", @@ -81,25 +104,7 @@ import { ImportLastPassComponent } from "./lastpass"; ImportLastPassComponent, RadioButtonModule, ], - providers: [ - { - provide: ImportApiServiceAbstraction, - useClass: ImportApiService, - deps: [ApiService], - }, - { - provide: ImportServiceAbstraction, - useClass: ImportService, - deps: [ - CipherService, - FolderService, - ImportApiServiceAbstraction, - I18nService, - CollectionService, - CryptoService, - ], - }, - ], + providers: safeProviders, }) export class ImportComponent implements OnInit, OnDestroy { featuredImportOptions: ImportOption[];