Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Livechat not rendering UiKit messages with action buttons #26327

Merged
merged 7 commits into from
Jul 21, 2022
22 changes: 14 additions & 8 deletions packages/livechat/src/lib/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const closeChat = async ({ transcriptRequested } = {}) => {
route('/chat-finished');
};

const getVideoConfMessageData = (message) => message.blocks?.find(({ appId }) => appId === 'videoconf-core')?.elements?.find(({ actionId }) => actionId === 'joinLivechat');
const getVideoConfMessageData = (message) =>
message.blocks?.find(({ appId }) => appId === 'videoconf-core')?.elements?.find(({ actionId }) => actionId === 'joinLivechat');

const isVideoCallMessage = (message) => {
if (message.t === constants.webRTCCallStartedMessageType) {
Expand Down Expand Up @@ -121,7 +122,12 @@ export const initRoom = async () => {

Livechat.unsubscribeAll();

const { token, agent, queueInfo, room: { _id: rid, servedBy } } = state;
const {
token,
agent,
queueInfo,
room: { _id: rid, servedBy },
} = state;
Livechat.subscribeRoom(rid);

let roomAgent = agent;
Expand Down Expand Up @@ -226,14 +232,15 @@ export const getGreetingMessages = (messages) => messages && messages.filter((ms
export const getLatestCallMessage = (messages) => messages && messages.filter((msg) => isVideoCallMessage(msg)).pop();

export const loadMessages = async () => {
const { ongoingCall } = store.state;
const { ongoingCall, messages: storedMessages, room } = store.state;

const { messages: storedMessages, room: { _id: rid, callStatus } = {} } = store.state;
const previousMessages = getGreetingMessages(storedMessages);
if (!rid) {
if (!room?._id) {
return;
}

const { _id: rid, callStatus } = room;
const previousMessages = getGreetingMessages(storedMessages);

await store.setState({ loading: true });
const rawMessages = (await Livechat.loadMessages(rid)).concat(previousMessages);
const messages = (await normalizeMessages(rawMessages)).map(transformAgentInformationOnMessage);
Expand Down Expand Up @@ -263,8 +270,7 @@ export const loadMessages = async () => {
},
incomingCallAlert: {
show: false,
callProvider:
latestCallMessage.t,
callProvider: latestCallMessage.t,
url: videoConfJoinBlock.url,
},
});
Expand Down