From 8a84692ea14f0a9ca40f2ea1ded58152ea4b5087 Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Thu, 21 Jul 2022 13:11:09 +0530 Subject: [PATCH 1/4] Regression: Livechat not rendering UiKit messages with action buttons --- packages/livechat/package.json | 2 +- yarn.lock | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/livechat/package.json b/packages/livechat/package.json index afdd30af342f..007b7b164a47 100644 --- a/packages/livechat/package.json +++ b/packages/livechat/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 91866e03eb29..e18ebb64499a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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.19": version: 0.32.0-dev.19 resolution: "@rocket.chat/ui-kit@npm:0.32.0-dev.19" From 0057666768f7689b7fa3ec4e6267aa1a7e5e53cd Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Thu, 21 Jul 2022 19:03:32 +0530 Subject: [PATCH 2/4] Fix conflicts --- packages/livechat/package.json | 2 +- yarn.lock | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/livechat/package.json b/packages/livechat/package.json index 007b7b164a47..ea26cd39f046 100644 --- a/packages/livechat/package.json +++ b/packages/livechat/package.json @@ -86,7 +86,7 @@ }, "dependencies": { "@rocket.chat/sdk": "^1.0.0-alpha.42", - "@rocket.chat/ui-kit": "^0.14.1", + "@rocket.chat/ui-kit": "0.14.1", "crypto-js": "^4.1.1", "css-vars-ponyfill": "^2.4.7", "date-fns": "^2.15.0", diff --git a/yarn.lock b/yarn.lock index b2450668fa66..f0bc70b1d476 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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": ^0.14.1 + "@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 @@ -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" From 9f1306f48632c9782a02946bc52bd93497bd0ec4 Mon Sep 17 00:00:00 2001 From: Aleksander Nicacio da Silva Date: Thu, 21 Jul 2022 10:41:59 -0300 Subject: [PATCH 3/4] [FIX] Fixed error thrown on loadMessages when room was null --- packages/livechat/src/lib/room.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/livechat/src/lib/room.js b/packages/livechat/src/lib/room.js index 5c74ba6096fb..1c7afea23d79 100644 --- a/packages/livechat/src/lib/room.js +++ b/packages/livechat/src/lib/room.js @@ -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) { @@ -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; @@ -205,7 +211,12 @@ Livechat.onMessage(async (message) => { message = transformAgentInformationOnMessage(message); await store.setState({ - messages: upsert(store.state.messages, message, ({ _id }) => _id === message._id, ({ ts }) => ts), + messages: upsert( + store.state.messages, + message, + ({ _id }) => _id === message._id, + ({ ts }) => ts, + ), }); await processMessage(message); @@ -226,14 +237,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); @@ -263,8 +275,7 @@ export const loadMessages = async () => { }, incomingCallAlert: { show: false, - callProvider: - latestCallMessage.t, + callProvider: latestCallMessage.t, url: videoConfJoinBlock.url, }, }); From 8f17ec4add0a7ed3f23b4637bdbed30e0e6a3b64 Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Thu, 21 Jul 2022 19:48:59 +0530 Subject: [PATCH 4/4] Attempt to fix build --- packages/livechat/src/lib/room.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/livechat/src/lib/room.js b/packages/livechat/src/lib/room.js index 1c7afea23d79..a15256ca4f42 100644 --- a/packages/livechat/src/lib/room.js +++ b/packages/livechat/src/lib/room.js @@ -211,12 +211,7 @@ Livechat.onMessage(async (message) => { message = transformAgentInformationOnMessage(message); await store.setState({ - messages: upsert( - store.state.messages, - message, - ({ _id }) => _id === message._id, - ({ ts }) => ts, - ), + messages: upsert(store.state.messages, message, ({ _id }) => _id === message._id, ({ ts }) => ts), }); await processMessage(message);