ADD: Save feedback and dirtyState

This commit is contained in:
Robert Kossessa
2024-03-22 15:48:32 +01:00
parent 9dbfcd7a1a
commit 95cd11d363
2 changed files with 10 additions and 4 deletions

View File

@@ -144,7 +144,7 @@
: 'border-2'
"
class="app-titlebar-button"
@click="console.log('Save not implemented!')"
@click="deviceStore.saveChangesOnDevice"
>
Save
</MenubarButton>

View File

@@ -117,9 +117,7 @@ export const useDeviceStore = defineStore('device', {
name = `name (${index})`
}
nanoIpc.send(this.currentDeviceId!, JSON.stringify({ profile: name }))
setTimeout(() => {
this.selectProfile(name)
}, 1000)
this.selectProfile(name)
},
addProfile(profile: Profile, updateDevice: boolean = true) {
if (!this.profileNames.includes(profile.name)) {
@@ -207,6 +205,13 @@ export const useDeviceStore = defineStore('device', {
nanoIpc.disconnect(deviceId)
}
},
setDirtyState(dirty: boolean) {
this.dirtyState = dirty
},
saveChangesOnDevice() {
this.setDirtyState(true)
nanoIpc.send(this.currentDeviceId!, JSON.stringify({ save: true }))
},
setProfileNames(profileNames: string[], updateDevice: boolean = true) {
this.profileNames = profileNames
if (updateDevice) {
@@ -287,6 +292,7 @@ export const initializeDevices = () => {
messageCallbacks.forEach((callback) => callback('Error', dataString))
}
if (eventid === 'saved') {
deviceStore.setDirtyState(false)
messageCallbacks.forEach((callback) => callback('Saved', 'Changes saved to device'))
}
if (eventid === 'device-attached') {