Skip to content

Commit

Permalink
avoid hitting 100% before print is complete
Browse files Browse the repository at this point in the history
The existing implementation will report 100% from 99.5% on, due to
round(). Switching to floor() instead, which will report 99% until
complete.

Signed-off-by: Jamin W. Collins <[email protected]>
  • Loading branch information
jamincollins committed Jul 9, 2023
1 parent ef2d17c commit 730681c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class App extends Mixins(BaseMixin) {
}
get print_percent(): number {
return Math.round(this.$store.getters['printer/getPrintPercent'] * 100)
return Math.floor(this.$store.getters['printer/getPrintPercent'] * 100)
}
@Watch('language')
Expand Down
2 changes: 1 addition & 1 deletion src/components/panels/StatusPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class StatusPanel extends Mixins(BaseMixin) {
}
get printPercent() {
return Math.round(this.$store.getters['printer/getPrintPercent'] * 100)
return Math.floor(this.$store.getters['printer/getPrintPercent'] * 100)
}
get printerStateOutput() {
Expand Down
2 changes: 1 addition & 1 deletion src/store/farm/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const getters: GetterTree<FarmPrinterState, any> = {
if (state.data.print_stats.state === 'printing') {
const percent = getters['getPrintPercent']

return Math.round(percent * 100) + '% Printing'
return Math.floor(percent * 100) + '% Printing'
}

return state.data.print_stats.state.charAt(0).toUpperCase() + state.data.print_stats.state.slice(1)
Expand Down
2 changes: 1 addition & 1 deletion src/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const getters: GetterTree<RootState, any> = {
// return printing title
if (printer_state === 'printing') {
const eta = getters['printer/getEstimatedTimeETAFormat']
const percent = (getters['printer/getPrintPercent'] * 100).toFixed(0)
const percent = Math.floor(getters['printer/getPrintPercent'] * 100)

if (eta !== '--') {
let output = i18n.t('App.Titles.PrintingETA', {
Expand Down

0 comments on commit 730681c

Please sign in to comment.