summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-10-09 13:50:45 +0000
committerXavier Dubuc <xdu@odoo.com>2020-10-29 11:45:42 +0000
commitecb56a6893dd7b76402c2262fb93f8dea079fde0 (patch)
tree1dd18589fbdbbb1efbba2a300fddaaae5fb49385 /addons/mail/static/src/components
parent1525dc7e4481cf9e24e6c5fff9a73df874670c97 (diff)
[FIX] mail: fix handling of lastVisibleMessage in channel seen condition
also fix a problem with composer.hasFocus field not always correctly updated (e.g. when switching from a channel to another in discuss) task-2278915 closes odoo/odoo#60079 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components')
-rw-r--r--addons/mail/static/src/components/composer/composer.xml1
-rw-r--r--addons/mail/static/src/components/composer_text_input/composer_text_input.js2
-rw-r--r--addons/mail/static/src/components/discuss/tests/discuss_tests.js47
3 files changed, 49 insertions, 1 deletions
diff --git a/addons/mail/static/src/components/composer/composer.xml b/addons/mail/static/src/components/composer/composer.xml
index ddd3368c21a..c85b5802863 100644
--- a/addons/mail/static/src/components/composer/composer.xml
+++ b/addons/mail/static/src/components/composer/composer.xml
@@ -83,6 +83,7 @@
t-on-o-composer-suggestion-clicked="_onComposerSuggestionClicked"
t-on-o-composer-text-input-send-shortcut="_onComposerTextInputSendShortcut"
t-on-paste="_onPasteTextInput"
+ t-key="composer.localId"
t-ref="textInput"
/>
<div class="o_Composer_buttons" t-att-class="{ 'o-composer-is-compact': props.isCompact, 'o-mobile': env.messaging.device.isMobile }">
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 068bdd303d4..9921b2912ae 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
@@ -179,7 +179,7 @@ class ComposerTextInput extends Component {
* @private
*/
_onFocusinTextarea() {
- this.composer.update({ hasFocus: true });
+ this.composer.focus();
}
/**
diff --git a/addons/mail/static/src/components/discuss/tests/discuss_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_tests.js
index 989bb75235e..77f7e875e42 100644
--- a/addons/mail/static/src/components/discuss/tests/discuss_tests.js
+++ b/addons/mail/static/src/components/discuss/tests/discuss_tests.js
@@ -4206,6 +4206,53 @@ QUnit.test('auto-focus composer on opening thread', async function (assert) {
);
});
+QUnit.test('mark channel as seen if last message is visible when switching channels when the previous channel had a more recent last message than the current channel', async function (assert) {
+ assert.expect(1);
+
+ this.data['mail.channel'].records.push(
+ { id: 10, message_unread_counter: 1, name: 'Bla' },
+ { id: 11, message_unread_counter: 1, name: 'Blu' },
+ );
+ this.data['mail.message'].records.push({
+ body: 'oldest message',
+ channel_ids: [10],
+ id: 10,
+ }, {
+ body: 'newest message',
+ channel_ids: [11],
+ id: 11,
+ });
+ await this.start({
+ discuss: {
+ context: {
+ active_id: 'mail.channel_11',
+ },
+ },
+ });
+ await afterNextRender(() => {
+ document.querySelector(`
+ .o_DiscussSidebar_item[data-thread-local-id="${
+ this.env.models['mail.thread'].findFromIdentifyingData({
+ id: 10,
+ model: 'mail.channel',
+ }).localId
+ }"]
+ `).click();
+ });
+ assert.doesNotHaveClass(
+ document.querySelector(`
+ .o_DiscussSidebar_item[data-thread-local-id="${
+ this.env.models['mail.thread'].findFromIdentifyingData({
+ id: 10,
+ model: 'mail.channel',
+ }).localId
+ }"]
+ `),
+ 'o-unread',
+ "sidebar item of channel ID 10 should no longer be unread"
+ );
+});
+
});
});
});