[FIX] im_livechat: fix send messages on closed chat window
Before this commit, sending a message on a livechat whose visitor closed the chat window would have resulted in a traceback being shown to the visitor. This was occurring when a message was sent by an operator or the welcome bot. An other related issue occurred when sending the feedback to the welcome bot. This commit fixes those issues by correctly guarding calls to `publicLivechatGlobal.chatWindow`. task-3010725 closes odoo/odoo#102752 X-original-commit: 524fc3e4cb0e63029e774e97de687998ccf06909 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Stockbauer Matthieu (tsm) <tsm@odoo.com>
This commit is contained in:
@@ -101,6 +101,9 @@ import LivechatButton from '@im_livechat/legacy/widgets/livechat_button';
|
||||
|
||||
this.messaging.publicLivechatGlobal.chatbot.update({
|
||||
welcomeMessageTimeout: setTimeout(() => {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
this._sendWelcomeChatbotMessage(stepIndex + 1, welcomeMessageDelay);
|
||||
this.messaging.publicLivechatGlobal.chatWindow.renderMessages();
|
||||
}, welcomeMessageDelay),
|
||||
|
||||
@@ -233,6 +233,9 @@ registerModel({
|
||||
this.messaging.publicLivechatGlobal.livechatButtonView.update({
|
||||
isTypingTimeout: setTimeout(
|
||||
() => {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
this.messaging.publicLivechatGlobal.chatWindow.widget.$('.o_mail_thread_content').append(
|
||||
$(qweb.render('im_livechat.legacy.chatbot.is_typing_message', {
|
||||
'chatbotImageSrc': `/im_livechat/operator/${
|
||||
@@ -253,6 +256,9 @@ registerModel({
|
||||
* This will receive the next step and call step processing.
|
||||
*/
|
||||
async triggerNextStep() {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
let triggerNextStep = true;
|
||||
if (
|
||||
this.currentStep &&
|
||||
|
||||
+9
@@ -39,6 +39,9 @@ registerModel({
|
||||
return;
|
||||
}
|
||||
case 'mail.channel.member/typing_status': {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
const channelMemberData = payload;
|
||||
if (channelMemberData.channel.id !== this.messaging.publicLivechatGlobal.publicLivechat.id) {
|
||||
return;
|
||||
@@ -58,6 +61,9 @@ registerModel({
|
||||
return;
|
||||
}
|
||||
case 'mail.channel/new_message': {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
if (payload.id !== this.messaging.publicLivechatGlobal.publicLivechat.id) {
|
||||
return;
|
||||
}
|
||||
@@ -75,6 +81,9 @@ registerModel({
|
||||
return;
|
||||
}
|
||||
case 'mail.message/insert': {
|
||||
if (!this.messaging.publicLivechatGlobal.chatWindow || !this.messaging.publicLivechatGlobal.chatWindow.exists()) {
|
||||
return;
|
||||
}
|
||||
const message = this.messaging.publicLivechatGlobal.messages.find(message => message.id === payload.id);
|
||||
if (!message) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user