[FIX] mail: stop squashing message if the previous message is deleted

closes odoo/odoo#77922

X-original-commit: 92c7f11e3c3cc70a3d520f0977f474e55dc7bced
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Samuel Degueldre
2021-10-05 19:13:38 +00:00
parent 11433284cf
commit e31464db54
4 changed files with 31 additions and 32 deletions
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="mail.DeleteMessageConfirmDialog" owl="1">
<Dialog contentClass="'o_DeleteMessageConfirmDialog'" title="title" t-on-dialog-closed="messageActionList.onDeleteConfirmDialogClosed" t-ref="dialog">
<p>Are you sure you want to delete this message?</p>
<blockquote class="o_DeleteMessageConfirmDialog_blockquote">
<Message messageViewLocalId="messageActionList.messageViewForDelete.localId"/>
</blockquote>
<small t-if="!messageActionList.message.originThread or messageActionList.message.originThread.model !== 'mail.channel'">Pay attention: The followers of this document who were notified by email will still be able to read the content of this message and reply to it.</small>
<t t-set-slot="buttons">
<button class="btn btn-primary" t-on-click="messageActionList.onClickConfirmDelete">Delete</button>
<button class="btn btn-secondary" t-on-click="dialogRef.comp._close()">Cancel</button>
<Dialog contentClass="'o_DeleteMessageConfirmDialog'" title="title" t-on-dialog-closed="messageActionList and messageActionList.onDeleteConfirmDialogClosed" t-ref="dialog">
<t t-if="messageActionList">
<p>Are you sure you want to delete this message?</p>
<blockquote class="o_DeleteMessageConfirmDialog_blockquote">
<Message messageViewLocalId="messageActionList.messageViewForDelete.localId"/>
</blockquote>
<small t-if="!messageActionList.message.originThread or messageActionList.message.originThread.model !== 'mail.channel'">Pay attention: The followers of this document who were notified by email will still be able to read the content of this message and reply to it.</small>
<t t-set-slot="buttons">
<button class="btn btn-primary" t-on-click="messageActionList.onClickConfirmDelete">Delete</button>
<button class="btn btn-secondary" t-on-click="dialogRef.comp._close()">Cancel</button>
</t>
</t>
</Dialog>
</t>
@@ -5,7 +5,7 @@
<div class="o_MessageList" t-att-class="{ 'o-empty': threadView and threadView.messages.length === 0 }" t-on-scroll="onScroll">
<t t-if="threadView">
<!-- No result messages -->
<t t-if="threadView.nonEmptyMessages.length === 0">
<t t-if="threadView.threadCache.orderedNonEmptyMessages.length === 0">
<div class="o_MessageList_empty o_MessageList_item">
<t t-if="threadView.thread === messaging.inbox">
<div class="o_MessageList_emptyTitle">
@@ -41,10 +41,10 @@
</button>
</div>
</t>
<t t-elif="threadView.order === 'asc' and threadView.messageViews.length > 0">
<t t-if="!threadView.threadCache.hasLoadingFailed and threadView.order === 'asc'">
<t t-call="mail.MessageList.loadMore"/>
</t>
<div t-if="threadView.order === 'asc' and threadView.nonEmptyMessages.length !== 0 and !(threadView and threadView.thread and threadView.thread.model === 'mail.box')" class="flex-grow-1"/>
<div t-if="threadView.order === 'asc' and threadView.threadCache.orderedNonEmptyMessages.length !== 0 and !(threadView and threadView.thread and threadView.thread.model === 'mail.box')" class="flex-grow-1"/>
<!-- MESSAGES -->
<t t-set="current_day" t-value="0"/>
<t t-foreach="threadView.messageViews" t-as="messageView" t-key="messageView.localId">
@@ -65,7 +65,7 @@
</t>
</t>
<!-- LOADING (if order desc)-->
<t t-if="!threadView.threadCache.hasLoadingFailed and threadView.order === 'desc' and threadView.messageViews.length > 0">
<t t-if="!threadView.threadCache.hasLoadingFailed and threadView.order === 'desc'">
<t t-call="mail.MessageList.loadMore"/>
</t>
</t>
@@ -138,15 +138,6 @@ function factory(dependencies) {
return replace(this.fetchedMessages.concat(newerMessages));
}
/**
*
* @private
* @returns {mail.message[]}
*/
_computeNonEmptyMessages() {
return replace(this.messages.filter(message => !message.isEmpty));
}
/**
* @private
* @returns {mail.message[]}
@@ -163,6 +154,15 @@ function factory(dependencies) {
return replace(this.messages.sort((m1, m2) => m1.id < m2.id ? -1 : 1));
}
/**
*
* @private
* @returns {mail.message[]}
*/
_computeOrderedNonEmptyMessages() {
return replace(this.orderedMessages.filter(message => !message.isEmpty));
}
/**
* @private
* @returns {boolean}
@@ -402,12 +402,6 @@ function factory(dependencies) {
messages: many2many('mail.message', {
compute: '_computeMessages',
}),
/**
* List of non empty messages linked to this cache.
*/
nonEmptyMessages: many2many('mail.message', {
compute: '_computeNonEmptyMessages',
}),
/**
* Ordered list of messages that have been fetched by this cache.
*
@@ -424,6 +418,12 @@ function factory(dependencies) {
orderedMessages: many2many('mail.message', {
compute: '_computeOrderedMessages',
}),
/**
* List of ordered non empty messages linked to this cache.
*/
orderedNonEmptyMessages: many2many('mail.message', {
compute: '_computeOrderedNonEmptyMessages',
}),
thread: one2one('mail.thread', {
inverse: 'cache',
readonly: true,
@@ -140,7 +140,7 @@ function factory(dependencies) {
if (!this.threadCache) {
return clear();
}
const orderedMessages = this.threadCache.orderedMessages;
const orderedMessages = this.threadCache.orderedNonEmptyMessages;
if (this.order === 'desc') {
orderedMessages.reverse();
}
@@ -478,9 +478,6 @@ function factory(dependencies) {
inverse: 'threadView',
isCausal: true,
}),
nonEmptyMessages: many2many('mail.message', {
related: 'threadCache.nonEmptyMessages',
}),
/**
* States the order mode of the messages on this thread view.
* Either 'asc', or 'desc'.