summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorPriyanka Kakadiya <pka@odoo.com>2021-02-15 10:35:51 +0000
committerSébastien Theys <seb@odoo.com>2021-03-26 17:22:04 +0000
commit7f28e68776849993f16b4b27e6213c0cce67de37 (patch)
treee137f68d83fcf6cf5b06a41d8bc9bdc6f77adfbc /addons
parentcf9d17eb344215a4872463d1942ab4111028fe21 (diff)
[FIX] mail: do not show typing when using a / command
PURPOSE: Currently typing status is sent when typing a command. SPECIFICATION: Typing status should not be sent when typing a command. Task-2363267 closes odoo/odoo#66821 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/static/src/components/composer/composer_tests.js79
-rw-r--r--addons/mail/static/src/components/composer_text_input/composer_text_input.js2
-rw-r--r--addons/mail/static/src/models/composer/composer.js6
3 files changed, 86 insertions, 1 deletions
diff --git a/addons/mail/static/src/components/composer/composer_tests.js b/addons/mail/static/src/components/composer/composer_tests.js
index 77a4f2adb4c..da0a2fb2901 100644
--- a/addons/mail/static/src/components/composer/composer_tests.js
+++ b/addons/mail/static/src/components/composer/composer_tests.js
@@ -696,6 +696,85 @@ QUnit.test('display command suggestions on typing "/"', async function (assert)
);
});
+QUnit.test('do not send typing notification on typing "/" command', async function (assert) {
+ assert.expect(1);
+
+ this.data['mail.channel'].records.push({ id: 20 });
+ this.data['mail.channel_command'].records.push({
+ channel_types: ['channel'],
+ help: "List users in the current channel",
+ name: "who",
+ });
+ await this.start({
+ async mockRPC(route, args) {
+ if (args.method === 'notify_typing') {
+ assert.step(`notify_typing:${args.kwargs.is_typing}`);
+ }
+ return this._super(...arguments);
+ },
+ });
+ const thread = this.env.models['mail.thread'].findFromIdentifyingData({
+ id: 20,
+ model: 'mail.channel',
+ });
+ await this.createComposerComponent(thread.composer, { hasThreadTyping: true });
+
+ await afterNextRender(() => {
+ document.querySelector(`.o_ComposerTextInput_textarea`).focus();
+ document.execCommand('insertText', false, "/");
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keydown'));
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keyup'));
+ });
+ assert.verifySteps([], "No rpc done");
+});
+
+QUnit.test('do not send typing notification on typing after selecting suggestion from "/" command', async function (assert) {
+ assert.expect(1);
+
+ this.data['mail.channel'].records.push({ id: 20 });
+ this.data['mail.channel_command'].records.push({
+ channel_types: ['channel'],
+ help: "List users in the current channel",
+ name: "who",
+ });
+ await this.start({
+ async mockRPC(route, args) {
+ if (args.method === 'notify_typing') {
+ assert.step(`notify_typing:${args.kwargs.is_typing}`);
+ }
+ return this._super(...arguments);
+ },
+ });
+ const thread = this.env.models['mail.thread'].findFromIdentifyingData({
+ id: 20,
+ model: 'mail.channel',
+ });
+ await this.createComposerComponent(thread.composer, { hasThreadTyping: true });
+
+ await afterNextRender(() => {
+ document.querySelector(`.o_ComposerTextInput_textarea`).focus();
+ document.execCommand('insertText', false, "/");
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keydown'));
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keyup'));
+ });
+ await afterNextRender(() =>
+ document.querySelector('.o_ComposerSuggestion').click()
+ );
+ await afterNextRender(() => {
+ document.querySelector(`.o_ComposerTextInput_textarea`).focus();
+ document.execCommand('insertText', false, " is user?");
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keydown'));
+ document.querySelector(`.o_ComposerTextInput_textarea`)
+ .dispatchEvent(new window.KeyboardEvent('keyup'));
+ });
+ assert.verifySteps([], "No rpc done");
+});
+
QUnit.test('use a command for a specific channel type', async function (assert) {
assert.expect(4);
diff --git a/addons/mail/static/src/components/composer_text_input/composer_text_input.js b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
index 7c11c7f5790..2bdd34da207 100644
--- a/addons/mail/static/src/components/composer_text_input/composer_text_input.js
+++ b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
@@ -220,12 +220,12 @@ class ComposerTextInput extends Component {
* @private
*/
_onInputTextarea() {
+ this.saveStateInStore();
if (this._textareaLastInputValue !== this._textareaRef.el.value) {
this.composer.handleCurrentPartnerIsTyping();
}
this._textareaLastInputValue = this._textareaRef.el.value;
this._updateHeight();
- this.saveStateInStore();
}
/**
diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js
index 3f6ac94a256..035f70921f3 100644
--- a/addons/mail/static/src/models/composer/composer.js
+++ b/addons/mail/static/src/models/composer/composer.js
@@ -311,6 +311,12 @@ function factory(dependencies) {
if (!this.thread) {
return;
}
+ if (
+ this.suggestionModelName === 'mail.channel_command' ||
+ this._getCommandFromText(this.textInputContent)
+ ) {
+ return;
+ }
if (this.thread.typingMembers.includes(this.env.messaging.currentPartner)) {
this.thread.refreshCurrentPartnerIsTyping();
} else {