Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Messages/MessageList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class MessageList extends MemoizedComponent {
attachmentResolver={attachmentResolver}
avatarResolver={avatarResolver}
use='li'
me={uid && message.u && uid === message.u._id}
me={!!message.token}
compact={nextMessage && message.u && nextMessage.u && message.u._id === nextMessage.u._id}
conversationFinishedMessage={conversationFinishedMessage}
{...message}
Expand Down
14 changes: 14 additions & 0 deletions src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ export const initRoom = async () => {
parentCall('callback', ['queue-position-change', queueInfo]);
});

Livechat.onVisitorChange(rid, async (newVisitor) => {
const { user: { _updatedAt = null } = {}, room } = store.state;
const { _id, token, username } = newVisitor;

Livechat.credentials.token = token;

await store.setState({
user: { _id, token, username, _updatedAt },
token,
room: { ...room, v: { _id, token, username } },
});
parentCall('callback', ['visitor-change', newVisitor]);
});

setCookies(rid, token);
};

Expand Down
2 changes: 2 additions & 0 deletions src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const validCallbacks = [
'agent-status-change',
'queue-position-change',
'no-agent-online',
'visitor-change',
];

const callbacks = mitt();
Expand Down Expand Up @@ -433,6 +434,7 @@ window.RocketChat.livechat = {
onAgentStatusChange(fn) { registerCallback('agent-status-change', fn); },
onQueuePositionChange(fn) { registerCallback('queue-position-change', fn); },
onServiceOffline(fn) { registerCallback('no-agent-online', fn); },
onVisitorChange(fn) { registerCallback('visitor-change', fn); },
};

// proccess queue
Expand Down