[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#68424 X-original-commit: 7f28e68776849993f16b4b27e6213c0cce67de37 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
committed by
Sébastien Theys
parent
8a5d22826c
commit
725a1b674d
@@ -791,6 +791,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);
|
||||
|
||||
|
||||
@@ -231,12 +231,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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -304,6 +304,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 {
|
||||
|
||||
Reference in New Issue
Block a user