diff --git a/tabby-core/src/services/vault.service.ts b/tabby-core/src/services/vault.service.ts index bcc507b3..8602597e 100644 --- a/tabby-core/src/services/vault.service.ts +++ b/tabby-core/src/services/vault.service.ts @@ -285,7 +285,7 @@ export class VaultFileProvider extends FileProvider { icon: 'fas fa-file', result: f, })), - ]) + ]).catch(() => null) if (result) { return `${this.prefix}${result.key.id}` } diff --git a/tabby-core/src/tabContextMenu.ts b/tabby-core/src/tabContextMenu.ts index 31ee3e1f..56c3c904 100644 --- a/tabby-core/src/tabContextMenu.ts +++ b/tabby-core/src/tabContextMenu.ts @@ -149,7 +149,7 @@ export class CommonOptionsContextMenu extends TabContextMenuItemProvider { click: async () => { const modal = this.ngbModal.open(PromptModalComponent) modal.componentInstance.prompt = this.translate.instant('Profile name') - const name = (await modal.result)?.value + const name = (await modal.result.catch(() => null))?.value if (!name) { return } diff --git a/tabby-settings/src/components/configSyncSettingsTab.component.ts b/tabby-settings/src/components/configSyncSettingsTab.component.ts index 8e41f624..0cb9c3e3 100644 --- a/tabby-settings/src/components/configSyncSettingsTab.component.ts +++ b/tabby-settings/src/components/configSyncSettingsTab.component.ts @@ -59,7 +59,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { const modal = this.ngbModal.open(PromptModalComponent) modal.componentInstance.prompt = this.translate.instant('Name for the new config') modal.componentInstance.value = name - name = (await modal.result)?.value + name = (await modal.result.catch(() => null))?.value if (!name) { return } diff --git a/tabby-settings/src/components/profilesSettingsTab.component.ts b/tabby-settings/src/components/profilesSettingsTab.component.ts index 41fb3e27..1e89b3e9 100644 --- a/tabby-settings/src/components/profilesSettingsTab.component.ts +++ b/tabby-settings/src/components/profilesSettingsTab.component.ts @@ -144,7 +144,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { async newProfileGroup (): Promise { const modal = this.ngbModal.open(PromptModalComponent) modal.componentInstance.prompt = this.translate.instant('New group name') - const result = await modal.result + const result = await modal.result.catch(() => null) if (result?.value.trim()) { await this.profilesService.newProfileGroup({ id: '', name: result.value }) } @@ -296,16 +296,17 @@ export class ProfilesSettingsTabComponent extends BaseComponent { modal.componentInstance.profile = Object.assign({}, model) modal.componentInstance.profileProvider = provider modal.componentInstance.defaultsMode = 'enabled' - const result = await modal.result - - // Fully replace the config - for (const k in model) { - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete model[k] + const result = await modal.result.catch(() => null) + if (result) { + // Fully replace the config + for (const k in model) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete model[k] + } + Object.assign(model, result) + this.profilesService.setProviderDefaults(provider, model) + await this.config.save() } - Object.assign(model, result) - this.profilesService.setProviderDefaults(provider, model) - await this.config.save() } async deleteDefaults (provider: ProfileProvider): Promise { diff --git a/tabby-settings/src/components/vaultSettingsTab.component.ts b/tabby-settings/src/components/vaultSettingsTab.component.ts index b34fa8d6..8f81b985 100644 --- a/tabby-settings/src/components/vaultSettingsTab.component.ts +++ b/tabby-settings/src/components/vaultSettingsTab.component.ts @@ -35,9 +35,11 @@ export class VaultSettingsTabComponent extends BaseComponent { async enableVault () { const modal = this.ngbModal.open(SetVaultPassphraseModalComponent) - const newPassphrase = await modal.result - await this.vault.setEnabled(true, newPassphrase) - this.vaultContents = await this.vault.load(newPassphrase) + const newPassphrase = await modal.result.catch(() => null) + if (newPassphrase) { + await this.vault.setEnabled(true, newPassphrase) + this.vaultContents = await this.vault.load(newPassphrase) + } } async disableVault () { @@ -65,8 +67,10 @@ export class VaultSettingsTabComponent extends BaseComponent { return } const modal = this.ngbModal.open(SetVaultPassphraseModalComponent) - const newPassphrase = await modal.result - this.vault.save(this.vaultContents, newPassphrase) + const newPassphrase = await modal.result.catch(() => null) + if (newPassphrase) { + this.vault.save(this.vaultContents, newPassphrase) + } } async toggleConfigEncrypted () { @@ -118,7 +122,7 @@ export class VaultSettingsTabComponent extends BaseComponent { modal.componentInstance.prompt = this.translate.instant('New name') modal.componentInstance.value = secret.key.description - const description = (await modal.result)?.value + const description = (await modal.result.catch(() => null))?.value if (!description) { return } diff --git a/tabby-ssh/src/components/sftpPanel.component.ts b/tabby-ssh/src/components/sftpPanel.component.ts index f0bcfbef..b24134d6 100644 --- a/tabby-ssh/src/components/sftpPanel.component.ts +++ b/tabby-ssh/src/components/sftpPanel.component.ts @@ -113,8 +113,8 @@ export class SFTPPanelComponent { async openCreateDirectoryModal (): Promise { const modal = this.ngbModal.open(SFTPCreateDirectoryModalComponent) - const directoryName = await modal.result - if (directoryName !== '') { + const directoryName = await modal.result.catch(() => null) + if (directoryName?.trim()) { this.sftp.mkdir(path.join(this.path, directoryName)).then(() => { this.notifications.notice('The directory was created successfully') this.navigate(path.join(this.path, directoryName)) diff --git a/tabby-ssh/src/components/sshProfileSettings.component.ts b/tabby-ssh/src/components/sshProfileSettings.component.ts index d2891e51..59f148d8 100644 --- a/tabby-ssh/src/components/sshProfileSettings.component.ts +++ b/tabby-ssh/src/components/sshProfileSettings.component.ts @@ -75,7 +75,7 @@ export class SSHProfileSettingsComponent { modal.componentInstance.prompt = `Password for ${this.profile.options.user}@${this.profile.options.host}` modal.componentInstance.password = true try { - const result = await modal.result + const result = await modal.result.catch(() => null) if (result?.value) { this.passwordStorage.savePassword(this.profile, result.value) this.hasSavedPassword = true @@ -89,11 +89,13 @@ export class SSHProfileSettingsComponent { } async addPrivateKey () { - const ref = await this.fileProviders.selectAndStoreFile(`private key for ${this.profile.name}`) - this.profile.options.privateKeys = [ - ...this.profile.options.privateKeys!, - ref, - ] + const ref = await this.fileProviders.selectAndStoreFile(`private key for ${this.profile.name}`).catch(() => null) + if (ref) { + this.profile.options.privateKeys = [ + ...this.profile.options.privateKeys!, + ref, + ] + } } removePrivateKey (path: string) { diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index f2931f57..02e77efe 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -210,7 +210,6 @@ export class SSHSession { if (!await this.verifyHostKey(handshake)) { this.ssh.end() reject(new Error('Host key verification failed')) - return } this.logger.info('Handshake complete:', handshake) resolve() @@ -300,7 +299,7 @@ export class SSHSession { const modal = this.ngbModal.open(PromptModalComponent) modal.componentInstance.prompt = `Username for ${this.profile.options.host}` try { - const result = await modal.result + const result = await modal.result.catch(() => null) this.authUsername = result?.value ?? null } catch { this.authUsername = 'root' @@ -428,11 +427,7 @@ export class SSHSession { const modal = this.ngbModal.open(HostKeyPromptModalComponent) modal.componentInstance.selector = selector modal.componentInstance.digest = this.hostKeyDigest - try { - return await modal.result - } catch { - return false - } + return modal.result.catch(() => false) } return true } @@ -495,7 +490,7 @@ export class SSHSession { modal.componentInstance.showRememberCheckbox = true try { - const result = await modal.result + const result = await modal.result.catch(() => null) if (result) { if (result.remember) { this.savedPassword = result.value diff --git a/tabby-ssh/src/sftpContextMenu.ts b/tabby-ssh/src/sftpContextMenu.ts index 5a3a8213..490e6ee8 100644 --- a/tabby-ssh/src/sftpContextMenu.ts +++ b/tabby-ssh/src/sftpContextMenu.ts @@ -53,6 +53,6 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider { const modal = this.ngbModal.open(SFTPDeleteModalComponent) modal.componentInstance.item = item modal.componentInstance.sftp = session - await modal.result + await modal.result.catch(() => {return}) } } diff --git a/tabby-terminal/src/tabContextMenu.ts b/tabby-terminal/src/tabContextMenu.ts index bef7cbba..817837f0 100644 --- a/tabby-terminal/src/tabContextMenu.ts +++ b/tabby-terminal/src/tabContextMenu.ts @@ -175,7 +175,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider { const modal = this.ngbModal.open(PromptModalComponent) modal.componentInstance.prompt = this.translate.instant('New profile name') modal.componentInstance.value = tab.profile.name - const name = (await modal.result)?.value + const name = (await modal.result.catch(() => null))?.value if (!name) { return }