From 148aff946270482233bed143ba80a9325ec21175 Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Fri, 1 Sep 2023 11:20:26 -0300 Subject: [PATCH 1/3] Add: Chat enums --- .../chat-header/chat-actions/component.tsx | 5 +++-- .../chat-graphql/chat-message-form/component.tsx | 5 +++-- .../chat-graphql/chat-message-list/component.tsx | 6 +++--- .../page/chat-message/componet.tsx | 16 +++++----------- .../imports/ui/core/enums/chat.ts | 14 ++++++++++++++ .../imports/ui/core/events/events.ts | 7 ------- 6 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 bigbluebutton-html5/imports/ui/core/enums/chat.ts delete mode 100644 bigbluebutton-html5/imports/ui/core/events/events.ts diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx index 50f3a39d82ad..e155f963b034 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx @@ -9,8 +9,9 @@ import { uid } from 'radash'; import Button from '/imports/ui/components/common/button/component'; import { clearPublicChatHistory, generateExportedMessages } from './services' import { getDateString } from '/imports/utils/string-utils'; -import Events from '/imports/ui/core/events/events'; + import { isEmpty } from 'ramda'; +import { ChatCommands, Commands } from '/imports/ui/core/enums/chat'; // @ts-ignore - temporary, while meteor exists in the project const CHAT_CONFIG = Meteor.settings.public.chat; @@ -144,7 +145,7 @@ export const ChatActions: React.FC = () => { dataTest: 'restoreWelcomeMessages', label: intl.formatMessage(intlMessages.showWelcomeMessage), onClick: () => { - const restoreWelcomeMessagesEvent = new CustomEvent(Events.RESTORE_WELCOME_MESSAGES); + const restoreWelcomeMessagesEvent = new CustomEvent(ChatCommands.RESTORE_WELCOME_MESSAGES); window.dispatchEvent(restoreWelcomeMessagesEvent); }, }, diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-form/component.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-form/component.tsx index 8d3fd0df1f45..656bed6a43de 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-form/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-form/component.tsx @@ -17,8 +17,9 @@ import { import { Chat } from '/imports/ui/Types/chat'; import { Layout } from '../../../layout/layoutTypes'; import { useMeeting } from '/imports/ui/core/hooks/useMeeting'; -import Events from '/imports/ui/core/events/events'; + import ChatOfflineIndicator from './chat-offline-indicator/component'; +import { ChatEvents } from '/imports/ui/core/enums/chat'; interface ChatMessageFormProps { minMessageLength: number, @@ -194,7 +195,7 @@ const ChatMessageForm: React.FC = ({ setHasErrors(false); setShowEmojiPicker(false); if (ENABLE_TYPING_INDICATOR) stopUserTyping(); - const sentMessageEvent = new CustomEvent(Events.SENT_MESSAGE); + const sentMessageEvent = new CustomEvent(ChatEvents.SENT_MESSAGE); window.dispatchEvent(sentMessageEvent); }; diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx index edda70bf7936..b28969cbf290 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx @@ -11,13 +11,13 @@ import { import { layoutSelect } from "../../../layout/context"; import ChatListPage from "./page/component"; import { defineMessages, useIntl } from "react-intl"; -import Events from "/imports/ui/core/events/events"; import useChat from "/imports/ui/core/hooks/useChat"; import { Chat } from "/imports/ui/Types/chat"; import { Message } from "/imports/ui/Types/message"; import { useCurrentUser } from "/imports/ui/core/hooks/useCurrentUser"; import { User } from "/imports/ui/Types/user"; import ChatPopupContainer from "../chat-popup/component"; +import { ChatEvents } from "/imports/ui/core/enums/chat"; // @ts-ignore - temporary, while meteor exists in the project const CHAT_CONFIG = Meteor.settings.public.chat; @@ -204,10 +204,10 @@ const ChatMessageList: React.FC = ({ } }; - window.addEventListener(Events.SENT_MESSAGE, setScrollToTailEventHandler); + window.addEventListener(ChatEvents.SENT_MESSAGE, setScrollToTailEventHandler); return () => { - window.removeEventListener(Events.SENT_MESSAGE, setScrollToTailEventHandler); + window.removeEventListener(ChatEvents.SENT_MESSAGE, setScrollToTailEventHandler); } }, [contentRef.current]); diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/componet.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/componet.tsx index 20b8b73cdfcf..72eeadc473b2 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/componet.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/componet.tsx @@ -10,7 +10,7 @@ import ChatMessageTextContent from "./message-content/text-content/component"; import ChatPollContent from "./message-content/poll-content/component"; import ChatMessagePresentationContent from "./message-content/presentation-content/component"; import { defineMessages, useIntl } from "react-intl"; - +import { ChatMessageType } from '/imports/ui/core/enums/chat'; interface ChatMessageProps { message: Message; @@ -20,12 +20,6 @@ interface ChatMessageProps { markMessageAsSeen: Function; } -const enum MessageType { - TEXT = 'default', - POLL = 'poll', - PRESENTATION = 'presentation', - CHAT_CLEAR = 'publicChatHistoryCleared' -} const intlMessages = defineMessages({ pollResult: { @@ -99,7 +93,7 @@ const ChatMesssage: React.FC = ({ component: React.ReactElement, } = useMemo(() => { switch (message.messageType) { - case MessageType.POLL: + case ChatMessageType.POLL: return { name: intl.formatMessage(intlMessages.pollResult), color: '#3B48A9', @@ -108,7 +102,7 @@ const ChatMesssage: React.FC = ({ ), }; - case MessageType.PRESENTATION: + case ChatMessageType.PRESENTATION: return { name: intl.formatMessage(intlMessages.presentationLabel), color: '#0F70D7', @@ -117,7 +111,7 @@ const ChatMesssage: React.FC = ({ ), }; - case MessageType.CHAT_CLEAR: + case ChatMessageType.CHAT_CLEAR: return { name: intl.formatMessage(intlMessages.systemLabel), color: '#0F70D7', @@ -129,7 +123,7 @@ const ChatMesssage: React.FC = ({ /> ), }; - case MessageType.TEXT: + case ChatMessageType.TEXT: default: return { name: message.user?.name, diff --git a/bigbluebutton-html5/imports/ui/core/enums/chat.ts b/bigbluebutton-html5/imports/ui/core/enums/chat.ts new file mode 100644 index 000000000000..13803ee58d6b --- /dev/null +++ b/bigbluebutton-html5/imports/ui/core/enums/chat.ts @@ -0,0 +1,14 @@ +export const enum ChatEvents { + SENT_MESSAGE = 'sentMessage', +} + +export const enum ChatCommands { + RESTORE_WELCOME_MESSAGES = 'restoreWelcomeMessages', +} + +export const enum ChatMessageType { + TEXT = 'default', + POLL = 'poll', + PRESENTATION = 'presentation', + CHAT_CLEAR = 'publicChatHistoryCleared' +} diff --git a/bigbluebutton-html5/imports/ui/core/events/events.ts b/bigbluebutton-html5/imports/ui/core/events/events.ts deleted file mode 100644 index b0aa306f2db3..000000000000 --- a/bigbluebutton-html5/imports/ui/core/events/events.ts +++ /dev/null @@ -1,7 +0,0 @@ - -const enum Events { - SENT_MESSAGE = 'sentMessage', - RESTORE_WELCOME_MESSAGES = 'restoreWelcomeMessages', -} - -export default Events; From 138f89f57c593ebd9bab7b39e4974fc4d91a20f2 Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Fri, 1 Sep 2023 11:24:33 -0300 Subject: [PATCH 2/3] Add commands to chat restore welcome message --- .../components/chat/chat-graphql/chat-popup/component.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-popup/component.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-popup/component.tsx index 415b44c1238e..5e00be462719 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-popup/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-popup/component.tsx @@ -3,9 +3,9 @@ import { PopupContainer, PopupContents } from './styles'; import { GET_WELCOME_MESSAGE, WelcomeMsgsResponse } from './queries'; import { useQuery } from '@apollo/client'; import PopupContent from './popup-content/component'; -import Events from '/imports/ui/core/events/events'; import { layoutSelect } from '../../../layout/context'; import { Layout } from '../../../layout/layoutTypes'; +import { ChatCommands } from '/imports/ui/core/enums/chat'; interface ChatPopupProps { welcomeMessage?: string | null; @@ -55,10 +55,10 @@ const ChatPopup: React.FC = ({ setWelcomeMsgsOnSession(WELCOME_MSG_FOR_MODERATORS_KEY, true); } }; - window.addEventListener(Events.RESTORE_WELCOME_MESSAGES, eventCallback); + window.addEventListener(ChatCommands.RESTORE_WELCOME_MESSAGES, eventCallback); return () => { - removeEventListener(Events.RESTORE_WELCOME_MESSAGES, eventCallback); + removeEventListener(ChatCommands.RESTORE_WELCOME_MESSAGES, eventCallback); } }, []); if (!showWelcomeMessage && !showWelcomeMessageForModerators) return null; From 99e498764fe71bd81bad178b3d670b97743e40fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Fri, 1 Sep 2023 11:51:31 -0300 Subject: [PATCH 3/3] Update bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx --- .../chat/chat-graphql/chat-header/chat-actions/component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx index e155f963b034..ff92b9f316ef 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/component.tsx @@ -11,7 +11,7 @@ import { clearPublicChatHistory, generateExportedMessages } from './services' import { getDateString } from '/imports/utils/string-utils'; import { isEmpty } from 'ramda'; -import { ChatCommands, Commands } from '/imports/ui/core/enums/chat'; +import { ChatCommands } from '/imports/ui/core/enums/chat'; // @ts-ignore - temporary, while meteor exists in the project const CHAT_CONFIG = Meteor.settings.public.chat;