mirror of
https://github.com/eugeny/tabby
synced 2025-12-11 18:25:57 +00:00
wip fix(core): deleteProfile & deleteGroupProfile 8e9156e250 48d4b8e8f8
This commit is contained in:
@@ -94,13 +94,20 @@ export class ProfilesService {
|
||||
* arg: saveConfig (default: true) -> invoke after the Profile was updated
|
||||
*/
|
||||
async writeProfile (profile: PartialProfile<Profile>, saveConfig = true): Promise<void> {
|
||||
this.deleteProfile(profile, false)
|
||||
const cProfile = this.config.store.profiles.find(p => p.id === profile.id)
|
||||
if (cProfile) {
|
||||
// Fully replace the config
|
||||
for (const k in cProfile) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete cProfile[k]
|
||||
}
|
||||
Object.assign(cProfile, profile)
|
||||
|
||||
this.config.store.profiles.push(profile)
|
||||
if (saveConfig) {
|
||||
return this.config.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Profile from config
|
||||
@@ -415,17 +422,19 @@ export class ProfilesService {
|
||||
* arg: saveConfig (default: true) -> invoke after the ProfileGroup was updated
|
||||
*/
|
||||
async writeProfileGroup (group: PartialProfileGroup<ProfileGroup>, saveConfig = true): Promise<void> {
|
||||
this.deleteProfileGroup(group, false, false)
|
||||
|
||||
delete group.profiles
|
||||
delete group.editable
|
||||
delete group.collapsed
|
||||
|
||||
this.config.store.groups.push(group)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user