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
Merged
Show file tree
Hide file tree
Changes from 6 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 packages/livechat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"@rocket.chat/sdk": "^1.0.0-alpha.42",
"@rocket.chat/ui-kit": "next",
"@rocket.chat/ui-kit": "0.14.1",
"crypto-js": "^4.1.1",
"css-vars-ponyfill": "^2.4.7",
"date-fns": "^2.15.0",
Expand Down
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
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ __metadata:
"@rocket.chat/fuselage-tokens": next
"@rocket.chat/logo": next
"@rocket.chat/sdk": ^1.0.0-alpha.42
"@rocket.chat/ui-kit": next
"@rocket.chat/ui-kit": 0.14.1
"@storybook/addon-actions": ^6.5.9
"@storybook/addon-backgrounds": ^6.5.9
"@storybook/addon-essentials": ^6.5.9
Expand Down Expand Up @@ -4281,6 +4281,13 @@ __metadata:
languageName: unknown
linkType: soft

"@rocket.chat/ui-kit@npm:0.14.1":
version: 0.14.1
resolution: "@rocket.chat/ui-kit@npm:0.14.1"
checksum: c9da95fbb079b2bbd39d746552083f0a67171347f303a3f27cad875f0eedf8d121d372fd0671c2ba9b2cd93b727fec10b01fe906cd71057a98872338c58f48bb
languageName: node
linkType: hard

"@rocket.chat/ui-kit@npm:next, @rocket.chat/ui-kit@npm:~0.32.0-dev.26":
version: 0.32.0-dev.26
resolution: "@rocket.chat/ui-kit@npm:0.32.0-dev.26"
Expand Down