Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mail_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"assets": {
"web.assets_backend": [
"mail_ux/static/src/core/common/**/*",
"mail_ux/static/src/views/composer_onchange.js",
],
},
"depends": [
Expand Down
27 changes: 27 additions & 0 deletions mail_ux/static/src/views/composer_onchange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ORM } from "@web/core/orm_service";
import { patch } from "@web/core/utils/patch";

// The composer dialog is rebuilt when an overlay (e.g. a tooltip) changes while it loads,
// which sends the same initial onchange again: reuse the pending one.
const pendingComposerOnchanges = new Map();

patch(ORM.prototype, {
call(model, method, args = [], kwargs = {}) {
const isInitialComposerOnchange =
model === "mail.compose.message" &&
method === "onchange" &&
Array.isArray(args[2]) &&
!args[2].length;
if (!isInitialComposerOnchange) {
return super.call(...arguments);
}
const key = JSON.stringify([args, kwargs]);
let prom = pendingComposerOnchanges.get(key);
if (!prom) {
prom = super.call(...arguments);
pendingComposerOnchanges.set(key, prom);
prom.finally(() => pendingComposerOnchanges.delete(key)).catch(() => {});
}
return prom.then((result) => structuredClone(result));
},
});
Loading