Skip to content

Commit d4f6aa1

Browse files
fix: Livechat conversation not closing due to cross-tab interference (#35168)
1 parent 9f6a7b4 commit d4f6aa1

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

.changeset/rude-llamas-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rocket.chat/livechat": patch
3+
---
4+
5+
Fixes Livechat conversation not closing in a few scenarios due to cross-tab interference

packages/livechat/src/lib/room.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ export const closeChat = async ({ transcriptRequested } = {}) => {
2424
await handleTranscript();
2525
}
2626

27-
const { room, department, config: { settings: { clearLocalStorageWhenChatEnded } = {} } = {} } = store.state;
28-
29-
if (!room) {
30-
console.warn('closeChat called without a room');
31-
return;
32-
}
27+
const { department, config: { settings: { clearLocalStorageWhenChatEnded } = {} } = {} } = store.state;
3328

3429
await store.setState({ room: null, renderedTriggers: [] });
3530

packages/livechat/src/routes/Chat/container.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component } from 'preact';
22
import { route } from 'preact-router';
33
import { withTranslation } from 'react-i18next';
44

5+
import Chat from './component';
56
import { Livechat } from '../../api';
67
import { ModalManager } from '../../components/Modal';
78
import { getAvatarUrl } from '../../helpers/baseUrl';
@@ -22,9 +23,8 @@ import constants from '../../lib/constants';
2223
import { getLastReadMessage, loadConfig, processUnread, shouldMarkAsUnread } from '../../lib/main';
2324
import { parentCall, runCallbackEventEmitter } from '../../lib/parentCall';
2425
import { createToken } from '../../lib/random';
25-
import { initRoom, closeChat, loadMessages, loadMoreMessages, defaultRoomParams, getGreetingMessages } from '../../lib/room';
26+
import { initRoom, loadMessages, loadMoreMessages, defaultRoomParams, getGreetingMessages } from '../../lib/room';
2627
import store from '../../store';
27-
import Chat from './component';
2828

2929
const ChatWrapper = ({ children, rid }) => {
3030
useRoomMessagesSubscription(rid);
@@ -254,7 +254,6 @@ class ChatContainer extends Component {
254254
await dispatch({ alerts: (alerts.push(alert), alerts) });
255255
} finally {
256256
await dispatch({ loading: false });
257-
await closeChat();
258257
}
259258
};
260259

0 commit comments

Comments
 (0)