mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
fix: avoid error Uncaught (in promise) on modal dismiss
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
async newProfileGroup (): Promise<void> {
|
||||
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<Profile>): Promise<void> {
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user