From e40a1cfcfca74125e4472f7c9b5839138d98d811 Mon Sep 17 00:00:00 2001
From: Tainan Felipe <tainanfelipe214@gmail.com>
Date: Wed, 17 Mar 2021 14:49:44 -0300
Subject: [PATCH] Fix posJoinMessage as undefined

---
 bigbluebutton-html5/imports/ui/components/chat/container.jsx  | 4 ++--
 .../imports/ui/components/user-list/service.js                | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bigbluebutton-html5/imports/ui/components/chat/container.jsx b/bigbluebutton-html5/imports/ui/components/chat/container.jsx
index 9048cc2736..e064cd08c1 100755
--- a/bigbluebutton-html5/imports/ui/components/chat/container.jsx
+++ b/bigbluebutton-html5/imports/ui/components/chat/container.jsx
@@ -123,8 +123,8 @@ const ChatContainer = (props) => {
   const contextChat = usingChatContext?.chats[isPublicChat ? PUBLIC_GROUP_CHAT_KEY : chatID];
   const lastTimeWindow = contextChat?.lastTimewindow;
   const lastMsg = contextChat && (isPublicChat
-    ? contextChat.preJoinMessages[lastTimeWindow] || contextChat.posJoinMessages[lastTimeWindow]
-    : contextChat.messageGroups[lastTimeWindow]);
+    ? contextChat?.preJoinMessages[lastTimeWindow] || contextChat?.posJoinMessages[lastTimeWindow]
+    : contextChat?.messageGroups[lastTimeWindow]);
   ChatLogger.debug('ChatContainer::render::chatData',contextChat);
   applyPropsToState = () => {
     ChatLogger.debug('ChatContainer::applyPropsToState::chatData',lastMsg, stateLastMsg, contextChat?.syncing);
diff --git a/bigbluebutton-html5/imports/ui/components/user-list/service.js b/bigbluebutton-html5/imports/ui/components/user-list/service.js
index 43704ec73a..938c328dce 100755
--- a/bigbluebutton-html5/imports/ui/components/user-list/service.js
+++ b/bigbluebutton-html5/imports/ui/components/user-list/service.js
@@ -250,8 +250,8 @@ const getActiveChats = ({ groupChatsMessages, groupChats, users }) => {
       const unreadTimewindows = contextChat.unreadTimeWindows;
       for (const unreadTimeWindowId of unreadTimewindows) {
         const timeWindow = (isPublicChat 
-          ? contextChat.preJoinMessages[unreadTimeWindowId] || contextChat.posJoinMessages[unreadTimeWindowId]
-          : contextChat.messageGroups[unreadTimeWindowId]);
+          ? contextChat?.preJoinMessages[unreadTimeWindowId] || contextChat?.posJoinMessages[unreadTimeWindowId]
+          : contextChat?.messageGroups[unreadTimeWindowId]);
         unreadMessagesCount += timeWindow.content.length;
       }
     }
-- 
GitLab