1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-23 05:03:36 +03:00

delay loading SSH importers until all plugins are ready

This commit is contained in:
Eugene Pankov 2023-01-29 13:17:30 +01:00
parent 2f5c6fafa9
commit 6ccb48fc62
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -1,4 +1,4 @@
import { Inject, Injectable, Optional } from '@angular/core'
import { Injectable, InjectFlags, Injector } from '@angular/core'
import { ProfileProvider, NewTabParameters, PartialProfile, TranslateService } from 'tabby-core'
import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
import { SSHProfileSettingsComponent } from './components/sshProfileSettings.component'
@ -49,7 +49,7 @@ export class SSHProfilesService extends ProfileProvider<SSHProfile> {
constructor (
private passwordStorage: PasswordStorageService,
private translate: TranslateService,
@Inject(SSHProfileImporter) @Optional() private importers: SSHProfileImporter[]|null,
private injector: Injector,
) {
super()
for (const k of Object.values(SSHAlgorithmType)) {
@ -65,12 +65,13 @@ export class SSHProfilesService extends ProfileProvider<SSHProfile> {
}
async getBuiltinProfiles (): Promise<PartialProfile<SSHProfile>[]> {
const importers = this.injector.get<SSHProfileImporter[]>(SSHProfileImporter as any, [], InjectFlags.Optional)
let imported: PartialProfile<SSHProfile>[] = []
for (const importer of this.importers ?? []) {
for (const importer of importers) {
try {
imported = imported.concat(await importer.getProfiles())
} catch (e) {
console.warn('Could not parse OpenSSH config:', e)
console.warn('Could not import SSH profiles:', e)
}
}
return [