diff --git a/src/renderer/src/components/profile/ProfileManager.vue b/src/renderer/src/components/profile/ProfileManager.vue index feb7808..149a079 100644 --- a/src/renderer/src/components/profile/ProfileManager.vue +++ b/src/renderer/src/components/profile/ProfileManager.vue @@ -126,7 +126,7 @@ deviceStore.duplicateProfile(originalName, profile) } " - @delete="console.log('Delete profile not implemented!')" + @delete="(profileName) => deviceStore.deleteProfile(profileName)" /> diff --git a/src/renderer/src/deviceStore.ts b/src/renderer/src/deviceStore.ts index 09dae5f..3dcda94 100644 --- a/src/renderer/src/deviceStore.ts +++ b/src/renderer/src/deviceStore.ts @@ -135,6 +135,23 @@ export const useDeviceStore = defineStore('device', { } } }, + deleteProfile(profileName: string, updateDevice: boolean = true) { + const index = this.profileNames.indexOf(profileName) + if (index !== -1) { + this.profileNames.splice(index, 1) + } + const profile = this.profiles.find((p) => p.name === profileName) + if (profile) { + const profileIndex = this.profiles.indexOf(profile) + this.profiles.splice(profileIndex, 1) + } + if (this.currentProfileName === profileName && this.profileNames.length > 0) { + this.selectProfile(this.profileNames[0], updateDevice) + } + if (updateDevice) { + nanoIpc.send(this.currentDeviceId!, JSON.stringify({ profiles: this.profileNames })) + } + }, duplicateProfile(profileName: string, updateDevice: boolean = true) { const profile = this.profiles.find((p) => p.name === profileName) if (profile) {