Skip to content

Commit

Permalink
refactor: minor code cleanup and simplification
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Oct 22, 2024
1 parent 24dadf8 commit 3a2d254
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
4 changes: 0 additions & 4 deletions src/mixins/toolhead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ export default class ToolheadMixin extends Vue {
return !!this.$store.getters['printer/getPrinterSettings']('stepper_z1') as boolean
}

get hasHomingOverride (): boolean {
return this.$store.getters['printer/getHasHomingOverride'] as boolean
}

get isManualProbeActive (): boolean {
return this.$store.getters['printer/getIsManualProbeActive'] as boolean
}
Expand Down
60 changes: 28 additions & 32 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,39 +914,44 @@ export const getters: GetterTree<PrinterState, RootState> = {
},

getHasWarnings: (state, getters, rootState) => {
if (
(rootState.socket && rootState.socket.open && rootState.socket.ready) &&
(getters.getPrinterWarnings.length > 0 || getters.getKlipperWarnings.length > 0 ||
getters.getMoonrakerFailedComponents.length > 0 || getters.getMoonrakerWarnings.length > 0)
) {
return true
} else {
return false
}
return (
rootState.socket &&
rootState.socket.open &&
rootState.socket.ready &&
(
getters.getPrinterWarnings.length > 0 ||
getters.getKlipperWarnings.length > 0 ||
getters.getMoonrakerFailedComponents.length > 0 ||
getters.getMoonrakerWarnings.length > 0
)
)
},

getPrinterWarnings: (state, getters) => {
const config = getters.getPrinterConfig()
const warnings = []

if (config && !('virtual_sdcard' in config)) {
warnings.push({ message: '[virtual_sdcard] not found in printer configuration.' })
}
if (config) {
if (!('virtual_sdcard' in config)) {
warnings.push({ message: '[virtual_sdcard] not found in printer configuration.' })
}

if (config && !('pause_resume' in config)) {
warnings.push({ message: '[pause_resume] not found in printer configuration.' })
}
if (!('pause_resume' in config)) {
warnings.push({ message: '[pause_resume] not found in printer configuration.' })
}

if (
config &&
!('display' in config) && !('display_status' in config)
) {
warnings.push({ message: '[display_status] is required if you do not have a [display] defined.' })
}
if (
!('display' in config) &&
!('display_status' in config)
) {
warnings.push({ message: '[display_status] is required if you do not have a [display] defined.' })
}

if (config && !('gcode_macro CANCEL_PRINT' in config)) {
warnings.push({ message: 'CANCEL_PRINT macro not found in configuration.' })
if (!('gcode_macro CANCEL_PRINT' in config)) {
warnings.push({ message: 'CANCEL_PRINT macro not found in configuration.' })
}
}

return warnings
},

Expand Down Expand Up @@ -978,15 +983,6 @@ export const getters: GetterTree<PrinterState, RootState> = {
return saveConfigPendingItems || {}
},

getHasHomingOverride: (state, getters) => {
const config = getters.getPrinterConfig()
if (config && ('homing_override' in config)) {
return true
} else {
return false
}
},

getHasRoundBed: (_, getters): boolean => {
const kinematics = getters.getPrinterSettings('printer.kinematics') || ''

Expand Down

0 comments on commit 3a2d254

Please sign in to comment.