diff --git a/addons/point_of_sale/static/src/js/ChromeWidgets/DebugWidget.js b/addons/point_of_sale/static/src/js/ChromeWidgets/DebugWidget.js index d462e44bbc2..4085ec41f92 100644 --- a/addons/point_of_sale/static/src/js/ChromeWidgets/DebugWidget.js +++ b/addons/point_of_sale/static/src/js/ChromeWidgets/DebugWidget.js @@ -1,6 +1,5 @@ /** @odoo-module */ -import { getFileAsText } from "@point_of_sale/js/utils"; import { parse } from "web.field_utils"; import NumberBuffer from "@point_of_sale/js/Misc/NumberBuffer"; import PosComponent from "@point_of_sale/js/PosComponent"; @@ -124,6 +123,7 @@ class DebugWidget extends PosComponent { var URL = window.URL || window.webkitURL; return URL.createObjectURL(this.paidOrdersBlob); } + // FIXME POSREF why is this two steps? prepareUnpaidOrders() { try { this.unpaidOrdersBlob = this._createBlob(this.env.pos.export_unpaid_orders()); @@ -142,7 +142,7 @@ class DebugWidget extends PosComponent { async importOrders(event) { const file = event.target.files[0]; if (file) { - const report = this.env.pos.import_orders(await getFileAsText(file)); + const report = this.env.pos.import_orders(await file.text()); await this.showPopup("OrderImportPopup", { report }); } } diff --git a/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js b/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js index 8355c7b449b..003310210b1 100644 --- a/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js +++ b/addons/point_of_sale/static/src/js/Misc/AbstractReceiptScreen.js @@ -1,6 +1,5 @@ /** @odoo-module */ -import { nextFrame } from "@point_of_sale/js/utils"; import PosComponent from "@point_of_sale/js/PosComponent"; import Registries from "@point_of_sale/js/Registries"; @@ -32,7 +31,7 @@ class AbstractReceiptScreen extends PosComponent { if (confirmed) { // We want to call the _printWeb when the popup is fully gone // from the screen which happens after the next animation frame. - await nextFrame(); + await new Promise(requestAnimationFrame); return await this._printWeb(); } return false; diff --git a/addons/point_of_sale/static/src/js/utils.js b/addons/point_of_sale/static/src/js/utils.js index 1d5cb197758..bf9e15c28fe 100644 --- a/addons/point_of_sale/static/src/js/utils.js +++ b/addons/point_of_sale/static/src/js/utils.js @@ -1,37 +1,4 @@ /** @odoo-module */ -export function getFileAsText(file) { - return new Promise((resolve, reject) => { - if (!file) { - reject(); - } else { - const reader = new FileReader(); - reader.addEventListener("load", function () { - resolve(reader.result); - }); - reader.addEventListener("abort", reject); - reader.addEventListener("error", reject); - reader.readAsText(file); - } - }); -} - -/** - * This global variable is used by nextFrame to store the timer and - * be able to cancel it before another request for animation frame. - */ -let timer = null; - -/** - * Wait for the next animation frame to finish. - */ -export const nextFrame = () => { - return new Promise((resolve) => { - cancelAnimationFrame(timer); - timer = requestAnimationFrame(() => { - resolve(); - }); - }); -}; /** * Creates a batched version of a callback so that all calls to it in the same