Skip to content

Commit

Permalink
fix: fix some issues with the presets (#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Sep 5, 2023
1 parent 9f08afc commit e0f5166
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
34 changes: 18 additions & 16 deletions src/store/gui/presets/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,24 @@ export const getters: GetterTree<GuiPresetsState, any> = {
text: '0 °C',
})

if ('presets' in state) {
Object.keys(state.presets).forEach((id: string) => {
const preset = state.presets[id]

if (
payload.name in preset.values &&
preset.values[payload.name].bool &&
output.findIndex((entry: preset) => entry.value === preset.values[payload.name].value) === -1
) {
output.push({
value: preset.values[payload.name].value,
text: preset.values[payload.name].value + ' °C',
})
}
})
}
// return only 0 entry, if there is no presets set
if (!('presets' in state)) return output

Object.keys(state.presets).forEach((id: string) => {
const preset = state.presets[id]

if (
payload.name in preset.values &&
preset.values[payload.name].bool &&
output.findIndex((entry: preset) => entry.value === preset.values[payload.name].value) === -1
) {
output.push({
// @ts-ignore
value: parseFloat(preset.values[payload.name].value),
text: preset.values[payload.name].value + ' °C',
})
}
})

return output.sort((a: preset, b: preset) => {
if (a.value > b.value) return -1
Expand Down
7 changes: 2 additions & 5 deletions src/store/gui/presets/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ export const mutations: MutationTree<GuiPresetsState> = {
},

update(state, payload) {
if (payload.id in state.presets) {
const preset = { ...state.presets[payload.id] }
Object.assign(preset, payload.values)
if (!(payload.id in state.presets)) return

Vue.set(state.presets, payload.id, preset)
}
Vue.set(state.presets, payload.id, payload.values)
},

updateCooldownGcode(state, payload) {
Expand Down

0 comments on commit e0f5166

Please sign in to comment.