summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorRomain Estievenart <res@odoo.com>2019-08-06 06:32:02 +0000
committerAdrien Dieudonne <adr@odoo.com>2019-08-19 13:01:30 +0000
commitf7fa3b7677ae1271b6e67d312b75f5eda5fce8eb (patch)
tree34bb87bb2df816c1988d4b751b84c765660cdd66 /addons/mail/static/src
parentdfa64cb7fef0e5097d870fe8f88af1304b4a23b0 (diff)
[REF] mail: MessagingMenu: extract "mark as read" code to dedicated method
This allow us to reuse this logic in enterprise when you swipe. Note that we could have directly called the handler but the name wasn't appropriate. So we preferred to extract some code in a well named function. Task ID : 1895453
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/systray/systray_messaging_menu.js50
1 files changed, 29 insertions, 21 deletions
diff --git a/addons/mail/static/src/js/systray/systray_messaging_menu.js b/addons/mail/static/src/js/systray/systray_messaging_menu.js
index f4c4eb48f39..9a9b21fe953 100644
--- a/addons/mail/static/src/js/systray/systray_messaging_menu.js
+++ b/addons/mail/static/src/js/systray/systray_messaging_menu.js
@@ -127,6 +127,34 @@ var MessagingMenu = Widget.extend({
return this.$el.hasClass('show');
},
/**
+ * Process Preview Mark As Read
+ *
+ * @private
+ * @param {Element} $preview
+ */
+ _markAsRead: function ($preview) {
+ var previewID = $preview.data('preview-id');
+ if (previewID === 'mailbox_inbox') {
+ var messageIDs = [].concat($preview.data('message-ids'));
+ this.call('mail_service', 'markMessagesAsRead', messageIDs);
+ } else if (previewID === 'mail_failure') {
+ var documentModel = $preview.data('document-model');
+ var unreadCounter = $preview.data('unread-counter');
+ this.do_action('mail.mail_resend_cancel_action', {
+ additional_context: {
+ default_model: documentModel,
+ unread_counter: unreadCounter
+ }
+ });
+ } else {
+ // this is mark as read on a thread
+ var thread = this.call('mail_service', 'getThread', previewID);
+ if (thread) {
+ thread.markAsRead();
+ }
+ }
+ },
+ /**
* Open discuss
*
* @private
@@ -315,28 +343,8 @@ var MessagingMenu = Widget.extend({
*/
_onClickPreviewMarkAsRead: function (ev) {
ev.stopPropagation();
- var thread;
var $preview = $(ev.currentTarget).closest('.o_mail_preview');
- var previewID = $preview.data('preview-id');
- if (previewID === 'mailbox_inbox') {
- var messageIDs = [].concat($preview.data('message-ids'));
- this.call('mail_service', 'markMessagesAsRead', messageIDs);
- } else if (previewID === 'mail_failure') {
- var documentModel = $preview.data('document-model');
- var unreadCounter = $preview.data('unread-counter');
- this.do_action('mail.mail_resend_cancel_action', {
- additional_context: {
- default_model: documentModel,
- unread_counter: unreadCounter
- }
- });
- } else {
- // this is mark as read on a thread
- thread = this.call('mail_service', 'getThread', previewID);
- if (thread) {
- thread.markAsRead();
- }
- }
+ this._markAsRead($preview);
},
});