diff --git a/tabby-core/src/services/profiles.service.ts b/tabby-core/src/services/profiles.service.ts index 51ab8acd..20be4ea3 100644 --- a/tabby-core/src/services/profiles.service.ts +++ b/tabby-core/src/services/profiles.service.ts @@ -93,10 +93,9 @@ export class ProfilesService { /** * Insert a new Profile in config - * arg: saveConfig (default: true) -> invoke after the Profile was updated * arg: genId (default: true) -> generate uuid in before pushing Profile into config */ - async newProfile (profile: PartialProfile, saveConfig = true, genId = true): Promise { + async newProfile (profile: PartialProfile, genId = true): Promise { if (genId) { profile.id = `${profile.type}:custom:${slugify(profile.name)}:${uuidv4()}` } @@ -107,17 +106,12 @@ export class ProfilesService { } this.config.store.profiles.push(profile) - - if (saveConfig) { - return this.config.save() - } } /** * Write a Profile in config - * arg: saveConfig (default: true) -> invoke after the Profile was updated */ - async writeProfile (profile: PartialProfile, saveConfig = true): Promise { + async writeProfile (profile: PartialProfile): Promise { const cProfile = this.config.store.profiles.find(p => p.id === profile.id) if (cProfile) { if (!profile.group) { @@ -125,18 +119,13 @@ export class ProfilesService { } Object.assign(cProfile, profile) - - if (saveConfig) { - return this.config.save() - } } } /** * Delete a Profile from config - * arg: saveConfig (default: true) -> invoke after the Profile was deleted */ - async deleteProfile (profile: PartialProfile, saveConfig = true): Promise { + async deleteProfile (profile: PartialProfile): Promise { this.providerForProfile(profile)?.deleteProfile(this.getConfigProxyForProfile(profile)) this.config.store.profiles = this.config.store.profiles.filter(p => p.id !== profile.id) @@ -147,18 +136,13 @@ export class ProfilesService { delete profileHotkeys[profileHotkeyName] this.config.store.hotkeys.profile = profileHotkeys } - - if (saveConfig) { - return this.config.save() - } } /** * Delete all Profiles from config using option filter * arg: options { group: string } -> options used to filter which profile have to be deleted - * arg: saveConfig (default: true) -> invoke after the Profile was deleted */ - async deleteBulkProfiles (options: { group: string }, saveConfig = true): Promise { + async deleteBulkProfiles (options: { group: string }): Promise { for (const profile of this.config.store.profiles.filter(p => p.group === options.group)) { this.providerForProfile(profile)?.deleteProfile(this.getConfigProxyForProfile(profile)) @@ -172,10 +156,6 @@ export class ProfilesService { } this.config.store.profiles = this.config.store.profiles.filter(p => p.group !== options.group) - - if (saveConfig) { - return this.config.save() - } } async openNewTabForProfile

(profile: PartialProfile

): Promise { @@ -464,10 +444,9 @@ export class ProfilesService { /** * Insert a new ProfileGroup in config - * arg: saveConfig (default: true) -> invoke after the Profile was updated * arg: genId (default: true) -> generate uuid in before pushing Profile into config */ - async newProfileGroup (group: PartialProfileGroup, saveConfig = true, genId = true): Promise { + async newProfileGroup (group: PartialProfileGroup, genId = true): Promise { if (genId) { group.id = `${uuidv4()}` } @@ -478,47 +457,33 @@ export class ProfilesService { } this.config.store.groups.push(group) - - if (saveConfig) { - return this.config.save() - } } /** * Write a ProfileGroup in config - * arg: saveConfig (default: true) -> invoke after the ProfileGroup was updated */ - async writeProfileGroup (group: PartialProfileGroup, saveConfig = true): Promise { + async writeProfileGroup (group: PartialProfileGroup): Promise { delete group.profiles delete group.editable const cGroup = this.config.store.groups.find(g => g.id === group.id) if (cGroup) { Object.assign(cGroup, group) - - if (saveConfig) { - return this.config.save() - } } } /** * Delete a ProfileGroup from config - * arg: saveConfig (default: true) -> invoke after the ProfileGroup was deleted */ - async deleteProfileGroup (group: PartialProfileGroup, saveConfig = true, deleteProfiles = true): Promise { + async deleteProfileGroup (group: PartialProfileGroup, deleteProfiles = true): Promise { this.config.store.groups = this.config.store.groups.filter(g => g.id !== group.id) if (deleteProfiles) { - await this.deleteBulkProfiles({ group: group.id }, false) + await this.deleteBulkProfiles({ group: group.id }) } else { for (const profile of this.config.store.profiles.filter(x => x.group === group.id)) { delete profile.group } } - - if (saveConfig) { - return this.config.save() - } } /** diff --git a/tabby-settings/src/components/profilesSettingsTab.component.ts b/tabby-settings/src/components/profilesSettingsTab.component.ts index d9cb446b..01063c0d 100644 --- a/tabby-settings/src/components/profilesSettingsTab.component.ts +++ b/tabby-settings/src/components/profilesSettingsTab.component.ts @@ -88,7 +88,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { const cfgProxy = this.profilesService.getConfigProxyForProfile(profile) profile.name = this.profilesService.providerForProfile(profile)?.getSuggestedName(cfgProxy) ?? this.translate.instant('{name} copy', base) } - this.profilesService.newProfile(profile) + this.profilesService.newProfile(profile).then(() => this.config.save()) } async editProfile (profile: PartialProfile): Promise { @@ -97,7 +97,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { return } Object.assign(profile, result) - await this.profilesService.writeProfile(profile) + await this.profilesService.writeProfile(profile).then(() => this.config.save()) } async showProfileEditModal (profile: PartialProfile): Promise|null> { @@ -140,7 +140,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { cancelId: 1, }, )).response === 0) { - this.profilesService.deleteProfile(profile) + this.profilesService.deleteProfile(profile).then(() => this.config.save()) } } @@ -149,7 +149,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { modal.componentInstance.prompt = this.translate.instant('New group name') const result = await modal.result.catch(() => null) if (result?.value.trim()) { - await this.profilesService.newProfileGroup({ id: '', name: result.value }) + await this.profilesService.newProfileGroup({ id: '', name: result.value }).then(() => this.config.save()) } } @@ -159,7 +159,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { return } Object.assign(group, result) - await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(group)) + await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(group)).then(() => this.config.save()) } async showProfileGroupEditModal (group: PartialProfileGroup): Promise|null> { @@ -239,7 +239,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent { deleteProfiles = true } - await this.profilesService.deleteProfileGroup(group, true, deleteProfiles) + await this.profilesService.deleteProfileGroup(group, deleteProfiles).then(() => this.config.save()) } }