Handle profile management

This commit is contained in:
ZXY101
2023-09-28 16:26:21 +02:00
parent 2e9a929b92
commit 9179bc750b
6 changed files with 183 additions and 43 deletions

View File

@@ -166,6 +166,28 @@ export function deleteProfile(profileId: string) {
})
}
export function renameProfile(oldName: string, newName: string) {
if (get(currentProfile) === oldName) {
currentProfile.set('Default');
}
profiles.update((profiles) => {
delete Object.assign(profiles, { [newName]: profiles[oldName] })[oldName];
return profiles
})
}
export function copyProfile(profileToCopy: string, newName: string) {
profiles.update((profiles) => {
return {
...profiles,
[newName]: {
...profiles[profileToCopy]
}
}
})
}
export function changeProfile(profileId: string) {
currentProfile.set(profileId)