mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-22 11:52:03 +03:00
ref(core): profiles.services deleteBulkProfiles filter with predicate function
This commit is contained in:
parent
5e5c80832d
commit
0128013308
@ -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)
|
||||
@ -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)
|
||||
}
|
||||
|
||||
async openNewTabForProfile <P extends Profile> (profile: PartialProfile<P>): Promise<BaseTabComponent|null> {
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user