Skip to content

Commit

Permalink
ref(core): profiles.services deleteBulkProfiles filter with predicate…
Browse files Browse the repository at this point in the history
… function
  • Loading branch information
Clem-Fern committed Aug 25, 2023
1 parent 5e5c808 commit 0128013
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tabby-core/src/services/profiles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export class ProfilesService {
* Delete all Profiles from config using option filter
* arg: options { group: string } -> options used to filter which profile have to be deleted
*/
async deleteBulkProfiles (options: { group: string }): Promise<void> {
for (const profile of this.config.store.profiles.filter(p => p.group === options.group)) {
async deleteBulkProfiles (filter: (p: PartialProfile<Profile>) => boolean): Promise<void> {
for (const profile of this.config.store.profiles.filter(filter)) {
this.providerForProfile(profile)?.deleteProfile(this.getConfigProxyForProfile(profile))

const profileHotkeyName = ProfilesService.getProfileHotkeyName(profile)
Expand All @@ -156,7 +156,7 @@ export class ProfilesService {
}
}

this.config.store.profiles = this.config.store.profiles.filter(p => p.group !== options.group)
this.config.store.profiles = this.config.store.profiles.filter(!filter)

This comment has been minimized.

Copy link
@Eugeny

Eugeny Aug 25, 2023

Owner

here, !filter equals just false, you want x => !filter(x)

}

async openNewTabForProfile <P extends Profile> (profile: PartialProfile<P>): Promise<BaseTabComponent|null> {
Expand Down Expand Up @@ -480,7 +480,7 @@ export class ProfilesService {
async deleteProfileGroup (group: PartialProfileGroup<ProfileGroup>, options?: { deleteProfiles?: boolean }): Promise<void> {
this.config.store.groups = this.config.store.groups.filter(g => g.id !== group.id)
if (options?.deleteProfiles) {
await this.deleteBulkProfiles({ group: group.id })
await this.deleteBulkProfiles((p) => p.group === group.id)
} else {
for (const profile of this.config.store.profiles.filter(x => x.group === group.id)) {
delete profile.group
Expand Down

0 comments on commit 0128013

Please sign in to comment.