summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/thread_view/thread_view.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/src/models/thread_view/thread_view.js')
-rw-r--r--addons/mail/static/src/models/thread_view/thread_view.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/addons/mail/static/src/models/thread_view/thread_view.js b/addons/mail/static/src/models/thread_view/thread_view.js
index 534fd2769a9..a7ccf0c7d4d 100644
--- a/addons/mail/static/src/models/thread_view/thread_view.js
+++ b/addons/mail/static/src/models/thread_view/thread_view.js
@@ -69,6 +69,33 @@ function factory(dependencies) {
/**
* @private
+ * @returns {mail.messaging}
+ */
+ _computeMessaging() {
+ return [['link', this.env.messaging]];
+ }
+
+ /**
+ * @private
+ * @returns {string[]}
+ */
+ _computeTextInputSendShortcuts() {
+ if (!this.thread) {
+ return;
+ }
+ const isMailingList = this.thread.model === 'mail.channel' && this.thread.mass_mailing;
+ // Actually in mobile there is a send button, so we need there 'enter' to allow new line.
+ // Hence, we want to use a different shortcut 'ctrl/meta enter' to send for small screen
+ // size with a non-mailing channel.
+ // here send will be done on clicking the button or using the 'ctrl/meta enter' shortcut.
+ if (this.env.messaging.device.isMobile || isMailingList) {
+ return ['ctrl-enter', 'meta-enter'];
+ }
+ return ['enter'];
+ }
+
+ /**
+ * @private
* @returns {integer|undefined}
*/
_computeThreadCacheInitialScrollHeight() {
@@ -199,6 +226,18 @@ function factory(dependencies) {
composer: many2one('mail.composer', {
related: 'thread.composer',
}),
+ /**
+ * Serves as compute dependency.
+ */
+ device: one2one('mail.device', {
+ related: 'messaging.device',
+ }),
+ /**
+ * Serves as compute dependency.
+ */
+ deviceIsMobile: attr({
+ related: 'device.isMobile',
+ }),
hasComposerFocus: attr({
related: 'composer.hasFocus',
}),
@@ -255,6 +294,12 @@ function factory(dependencies) {
messages: many2many('mail.message', {
related: 'threadCache.messages',
}),
+ /**
+ * Serves as compute dependency.
+ */
+ messaging: many2one('mail.messaging', {
+ compute: '_computeMessaging',
+ }),
nonEmptyMessages: many2many('mail.message', {
related: 'threadCache.nonEmptyMessages',
}),
@@ -288,6 +333,20 @@ function factory(dependencies) {
related: 'threadViewer.stringifiedDomain',
}),
/**
+ * Determines the keyboard shortcuts that are available to send a message
+ * from the composer of this thread viewer.
+ */
+ textInputSendShortcuts: attr({
+ compute: '_computeTextInputSendShortcuts',
+ dependencies: [
+ 'device',
+ 'deviceIsMobile',
+ 'thread',
+ 'threadMassMailing',
+ 'threadModel',
+ ],
+ }),
+ /**
* Determines the `mail.thread` currently displayed by `this`.
*/
thread: many2one('mail.thread', {
@@ -336,6 +395,18 @@ function factory(dependencies) {
related: 'threadViewer.threadCacheInitialScrollPositions',
}),
/**
+ * Serves as compute dependency.
+ */
+ threadMassMailing: attr({
+ related: 'thread.mass_mailing',
+ }),
+ /**
+ * Serves as compute dependency.
+ */
+ threadModel: attr({
+ related: 'thread.model',
+ }),
+ /**
* Not a real field, used to trigger `thread.markAsSeen` when one of
* the dependencies changes.
*/