[REF] web, *: remove legacy delay
In our continued effort to remove legacy code, this commit replaces usage of the legacy delay util with a new delay util. The legacy delay has been removed. Part-of task-id 3439226 Part-of: odoo/odoo#132559
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
/**
|
||||
* Returns a promise resolved after 'wait' milliseconds
|
||||
*
|
||||
* @param {int} [wait=0] the delay in ms
|
||||
* @return {Promise}
|
||||
*/
|
||||
export function delay(wait) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(resolve, wait);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* KeepLast is a concurrency primitive that manages a list of tasks, and only
|
||||
* keeps the last task active.
|
||||
|
||||
@@ -17,17 +17,6 @@
|
||||
import Class from "@web/legacy/js/core/class";
|
||||
|
||||
const concurrency = {
|
||||
/**
|
||||
* Returns a promise resolved after 'wait' milliseconds
|
||||
*
|
||||
* @param {int} [wait=0] the delay in ms
|
||||
* @return {Promise}
|
||||
*/
|
||||
delay: function (wait) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(resolve, wait);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* The DropMisordered abstraction is useful for situations where you have
|
||||
* a sequence of operations that you want to do, but if one of them
|
||||
@@ -179,5 +168,4 @@ const concurrency = {
|
||||
}
|
||||
};
|
||||
|
||||
export const delay = concurrency.delay
|
||||
export default concurrency;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
import { uniqueId } from "@web/core/utils/functions";
|
||||
import concurrency from "@web/legacy/js/core/concurrency";
|
||||
import { delay } from "@web/core/utils/concurrency";
|
||||
import core from "@web/legacy/js/services/core";
|
||||
import { localization } from "@web/core/l10n/localization";
|
||||
|
||||
@@ -347,7 +347,7 @@ var dom = {
|
||||
// a 'real' debounce creation useless. Also, during the debouncing
|
||||
// part, the button is disabled without any visual effect.
|
||||
$button.addClass('pe-none');
|
||||
Promise.resolve(dom.DEBOUNCE && concurrency.delay(dom.DEBOUNCE)).then(function () {
|
||||
Promise.resolve(dom.DEBOUNCE && delay(dom.DEBOUNCE)).then(function () {
|
||||
$button.removeClass('pe-none');
|
||||
const restore = dom.addButtonLoadingEffect($button[0]);
|
||||
return Promise.resolve(result).then(restore).guardedCatch(restore);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { delay } from "@web/legacy/js/core/concurrency";
|
||||
import { delay } from "@web/core/utils/concurrency";
|
||||
import { loadJS } from "@web/core/assets";
|
||||
import { isVideoElementReady, buildZXingBarcodeDetector } from "./ZXingBarcodeDetector";
|
||||
import { CropOverlay } from "./crop_overlay";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import concurrency from "@web/legacy/js/core/concurrency";
|
||||
import { delay } from "@web/core/utils/concurrency";
|
||||
|
||||
/**
|
||||
* DOM Test Utils
|
||||
@@ -305,7 +305,7 @@ import concurrency from "@web/legacy/js/core/concurrency";
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async function returnAfterNextAnimationFrame() {
|
||||
await concurrency.delay(0);
|
||||
await delay(0);
|
||||
await new Promise(resolve => {
|
||||
window.requestAnimationFrame(resolve);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import concurrency from '@web/legacy/js/core/concurrency';
|
||||
import { delay } from "@web/core/utils/concurrency";
|
||||
import utils from '@web/legacy/js/core/utils';
|
||||
import weUtils from '@web_editor/js/common/utils';
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
@@ -332,7 +332,7 @@ class ApplyConfiguratorScreen extends Component {
|
||||
);
|
||||
} catch (error) {
|
||||
// Wait a bit before retrying or allowing manual retry.
|
||||
await concurrency.delay(5000);
|
||||
await delay(5000);
|
||||
if (retryCount < 3) {
|
||||
return attemptConfiguratorApply(data, retryCount + 1);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import ajax from "@web/legacy/js/core/ajax";
|
||||
import publicWidget from "@web/legacy/js/public/public_widget";
|
||||
import dom from "@web/legacy/js/core/dom";
|
||||
import concurrency from "@web/legacy/js/core/concurrency";
|
||||
import { delay } from "@web/core/utils/concurrency";
|
||||
import { debounce } from "@web/core/utils/timing";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { renderToElement } from "@web/core/utils/render";
|
||||
@@ -436,7 +436,7 @@
|
||||
// Prevent double-clicking on the send button and
|
||||
// add a upload loading effect (delay before success
|
||||
// message)
|
||||
await concurrency.delay(dom.DEBOUNCE);
|
||||
await delay(dom.DEBOUNCE);
|
||||
|
||||
self.el.classList.add('d-none');
|
||||
self.el.parentElement.querySelector('.s_website_form_end_message').classList.remove('d-none');
|
||||
@@ -446,7 +446,7 @@
|
||||
// Prevent double-clicking on the send button and
|
||||
// add a upload loading effect (delay before success
|
||||
// message)
|
||||
await concurrency.delay(dom.DEBOUNCE);
|
||||
await delay(dom.DEBOUNCE);
|
||||
|
||||
self.update_status('success');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user