From 3c12f91fdaf5a5ee402e7b1e7b188f411a4f72ff Mon Sep 17 00:00:00 2001 From: "Didier (did)" Date: Thu, 17 Sep 2020 13:11:36 +0000 Subject: [PATCH] [FIX] mail: avoid flicker when uploading multiple attachement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit task-2282327 closes odoo/odoo#58358 X-original-commit: 413c6c406eac52048b9a0b80c7ee46efe5b061c4 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/models/thread/thread.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/models/thread/thread.js b/addons/mail/static/src/models/thread/thread.js index bed46a7f41b..01737253e6c 100644 --- a/addons/mail/static/src/models/thread/thread.js +++ b/addons/mail/static/src/models/thread/thread.js @@ -883,7 +883,17 @@ function factory(dependencies) { */ _computeAllAttachments() { const allAttachments = [...new Set(this.originThreadAttachments.concat(this.attachments))] - .sort((a1, a2) => a1.id < a2.id ? 1 : -1); + .sort((a1, a2) => { + // "uploading" before "uploaded" attachments. + if (!a1.isTemporary && a2.isTemporary) { + return 1; + } + if (a1.isTemporary && !a2.isTemporary) { + return -1; + } + // "most-recent" before "oldest" attachments. + return Math.abs(a2.id) - Math.abs(a1.id); + }); return [['replace', allAttachments]]; }