diff --git a/addons/mail/static/src/models/thread.js b/addons/mail/static/src/models/thread.js index 4d550b504a2..657f643749a 100644 --- a/addons/mail/static/src/models/thread.js +++ b/addons/mail/static/src/models/thread.js @@ -1010,7 +1010,7 @@ Model({ this.update({ isCurrentPartnerTyping: false, orderedTypingMembers: newOrderedTypingMembers, - typingMembers: unlink(memberOfCurrentUser), + typingMembers: memberOfCurrentUser ? unlink(memberOfCurrentUser) : undefined, }); // Notify typing status to other members. if (immediateNotify) { diff --git a/addons/mail/static/tests/helpers/mock_server/controllers/discuss.js b/addons/mail/static/tests/helpers/mock_server/controllers/discuss.js index 364d296da3c..7b94b9f2b46 100644 --- a/addons/mail/static/tests/helpers/mock_server/controllers/discuss.js +++ b/addons/mail/static/tests/helpers/mock_server/controllers/discuss.js @@ -180,6 +180,9 @@ patch(MockServer.prototype, "mail/controllers/discuss", { ["channel_id", "=", channel_id], ["partner_id", "=", partnerId], ]); + if (!memberOfCurrentUser) { + return; + } this._mockMailChannelMember_NotifyTyping([memberOfCurrentUser.id], is_typing); }, /** diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index ec3b84ae202..6fc242924f2 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -404,6 +404,7 @@ export { afterNextRender, dragenterFiles, dropFiles, + insertText, isScrolledToBottom, nextAnimationFrame, nextTick, diff --git a/addons/mail/static/tests/qunit_suite_tests/components/composer_tests.js b/addons/mail/static/tests/qunit_suite_tests/components/composer_tests.js index 5dd155b7441..467461063b3 100644 --- a/addons/mail/static/tests/qunit_suite_tests/components/composer_tests.js +++ b/addons/mail/static/tests/qunit_suite_tests/components/composer_tests.js @@ -4,6 +4,7 @@ import { afterNextRender, dragenterFiles, dropFiles, + insertText, nextAnimationFrame, pasteFiles, start, @@ -1729,4 +1730,42 @@ QUnit.module("mail", {}, function () { } ); }); + + QUnit.test( + "No error when typing timeout occurs after closing the channel", + async function (assert) { + const pyEnv = await startServer(); + const partnerId = pyEnv["res.partner"].create({ + im_status: "online", + name: "Demo", + }); + const channelId = pyEnv["mail.channel"].create({ + name: "Gryffindor", + channel_member_ids: [ + [0, 0, { partner_id: pyEnv.currentPartnerId }], + [0, 0, { partner_id: partnerId }], + ], + }); + const { advanceTime, click, messaging, openDiscuss } = await start({ + hasTimeControl: true, + discuss: { + context: { + active_id: channelId, + }, + }, + }); + await openDiscuss(); + await afterNextRender(() => insertText(".o_ComposerTextInputView_textarea", "Hello")); + await click(".o_DiscussSidebarCategoryItem_commandLeave"); + const thread = messaging.models["Thread"].findFromIdentifyingData({ + id: channelId, + model: "mail.channel", + }); + const { duration } = messaging.models["Timer"].findFromIdentifyingData({ + threadAsCurrentPartnerInactiveTypingTimerOwner: thread, + }); + await advanceTime(duration); + assert.containsNone(document.body, ".o_DiscussSidebarCategoryItem"); + } + ); });