[FIX] mail: no traceback on receiving seen notification
Before this commit, when we post a message and someone has received it, there could be a traceback. Steps to reproduce: 1. Two users are logged in. 2. On one user: - open any app except Discuss - From systray messaging menu, click on "New messages" - Open Discuss - Post a message in a direct chat with other User. > traceback `Cannot read property 'getID' of null` closes odoo/odoo#31228
This commit is contained in:
@@ -377,6 +377,9 @@ var ThreadWindow = AbstractThreadWindow.extend({
|
||||
* @param {integer} channelID
|
||||
*/
|
||||
_onUpdateChannel: function (channelID) {
|
||||
if (!this.hasThread()) {
|
||||
return;
|
||||
}
|
||||
if (this._thread.getID() !== channelID) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -634,6 +634,50 @@ QUnit.test("messaging menu widget: channel seen notification", function (assert)
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("messaging menu widget: no traceback when receiving channel_fetched notification with blank thread window", function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
this.data.initMessaging.channel_slots = {
|
||||
channel_direct_message: [{
|
||||
id: 1,
|
||||
channel_type: "chat",
|
||||
direct_partner: [{ id: 2, name: 'Someone', im_status: '' }],
|
||||
name: 'DM',
|
||||
message_unread_counter: 1,
|
||||
}],
|
||||
};
|
||||
|
||||
var messagingMenu = new MessagingMenu();
|
||||
testUtils.mock.addMockEnvironment(messagingMenu, {
|
||||
services: this.services,
|
||||
data: this.data,
|
||||
session: { partner_id: 3 },
|
||||
});
|
||||
|
||||
messagingMenu.appendTo($('#qunit-fixture'));
|
||||
messagingMenu.$('.dropdown-toggle').click();
|
||||
assert.containsOnce(messagingMenu, '.o_new_message',
|
||||
"should have button to open blank thread window");
|
||||
|
||||
testUtils.dom.click(messagingMenu.$('.o_new_message'));
|
||||
var $threadWindow = $('.o_thread_window');
|
||||
assert.strictEqual($threadWindow.length, 1, "should have an open thread window");
|
||||
assert.ok($threadWindow.hasClass('o_thread_less'), "should be a blank thread window");
|
||||
|
||||
// Simulate received channel fetched notification
|
||||
var message = {
|
||||
info: 'channel_fetched',
|
||||
last_message_id: 1,
|
||||
partner_id: 2,
|
||||
};
|
||||
var notifications = [
|
||||
[['myDB', 'mail.channel', 1], message]
|
||||
];
|
||||
messagingMenu.call('bus_service', 'trigger', 'notification', notifications);
|
||||
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("messaging menu widget: preview with no message should be undated", function ( assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user