Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
fix issue where roomId was getting changed and message alignment issu…
Browse files Browse the repository at this point in the history
…e fixed
  • Loading branch information
murtaza98 committed Aug 14, 2020
1 parent 197158b commit 644d712
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion size-plugin.json

Large diffs are not rendered by default.

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={(uid && message.u && uid === message.u._id) || message.token}
compact={nextMessage && message.u && nextMessage.u && message.u._id === nextMessage.u._id}
conversationFinishedMessage={conversationFinishedMessage}
{...message}
Expand Down
34 changes: 34 additions & 0 deletions src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,40 @@ export const loadConfig = async () => {
});
};

export const reloadConfig = async () => {
const {
token,
room: { _id: roomId = null } = {},
messages,
typing,
} = store.state;

Livechat.credentials.token = token;

const {
agent,
room,
guest: user,
resources: { sound: src = null } = {},
queueInfo,
...config
} = await Livechat.config({
token,
...roomId && { roomId },
});

await store.setState({
config,
agent: agent && agent.hiddenInfo ? { hiddenInfo: true } : agent, // TODO: revert it when the API is updated
room,
user,
queueInfo,
sound: { src, enabled: true, play: false },
messages,
typing,
});
};

export const processUnread = async () => {
const { minimized, visible, messages } = store.state;
if (minimized || !visible) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { setCookies, upsert, canRenderMessage } from '../components/helpers';
import { store } from '../store';
import { normalizeAgent } from './api';
import Commands from './commands';
import { loadConfig, processUnread } from './main';
import { loadConfig, processUnread, reloadConfig } from './main';
import { parentCall } from './parentCall';
import { normalizeMessage, normalizeMessages } from './threads';
import { handleTranscript } from './transcript';
Expand Down Expand Up @@ -90,7 +90,7 @@ export const initRoom = async () => {
token,
room: { ...room, v: { _id, token, username } },
});
await loadConfig();
await reloadConfig();
});

setCookies(rid, token);
Expand Down

0 comments on commit 644d712

Please sign in to comment.