From 730681c07a41e4391b458c0380c7edfa2172b640 Mon Sep 17 00:00:00 2001 From: "Jamin W. Collins" Date: Fri, 7 Jul 2023 14:38:20 -0600 Subject: [PATCH] avoid hitting 100% before print is complete 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 --- src/App.vue | 2 +- src/components/panels/StatusPanel.vue | 2 +- src/store/farm/printer/getters.ts | 2 +- src/store/getters.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index f24eebf0a..24aacef7b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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') diff --git a/src/components/panels/StatusPanel.vue b/src/components/panels/StatusPanel.vue index 190e6ab0b..a7e793541 100644 --- a/src/components/panels/StatusPanel.vue +++ b/src/components/panels/StatusPanel.vue @@ -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() { diff --git a/src/store/farm/printer/getters.ts b/src/store/farm/printer/getters.ts index 41406c149..effebc8b4 100644 --- a/src/store/farm/printer/getters.ts +++ b/src/store/farm/printer/getters.ts @@ -52,7 +52,7 @@ export const getters: GetterTree = { 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) diff --git a/src/store/getters.ts b/src/store/getters.ts index c90386100..2cedd12b3 100644 --- a/src/store/getters.ts +++ b/src/store/getters.ts @@ -38,7 +38,7 @@ export const getters: GetterTree = { // 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', {