From d32a122aee6095304f60ea8aa8d097b2c09439e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Fri, 1 Sep 2023 13:14:41 -0300 Subject: [PATCH] import message type enum --- .../chat-header/chat-actions/services.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/services.ts b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/services.ts index 727c317ad66b..be6cbc1b06a2 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/services.ts +++ b/bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-header/chat-actions/services.ts @@ -2,13 +2,7 @@ import { Message } from "/imports/ui/Types/message"; import { makeCall } from "/imports/ui/services/api"; import { stripTags, unescapeHtml } from '/imports/utils/string-utils'; import { defineMessages } from 'react-intl'; - -const enum MessageType { - TEXT = 'default', - POLL = 'poll', - PRESENTATION = 'presentation', - CHAT_CLEAR = 'publicChatHistoryCleared' -} +import { ChatMessageType } from '/imports/ui/core/enums/chat'; const intlMessages = defineMessages({ chatClear: { @@ -22,10 +16,10 @@ export const htmlDecode = (input: string) => { return unescapeHtml(stripTags(replacedBRs)); }; -export const generateExportedMessages = (messages: Array, welcomeSettings: {welcomeMsg: string, welcomeMsgForModerators: string | null}, intl ): string => { +export const generateExportedMessages = (messages: Array, welcomeSettings: { welcomeMsg: string, welcomeMsgForModerators: string | null }, intl): string => { const welcomeMessage = htmlDecode(welcomeSettings.welcomeMsg); const modOnlyMessage = welcomeSettings.welcomeMsgForModerators && htmlDecode(welcomeSettings.welcomeMsgForModerators); - const systemMessages = `${welcomeMessage ? `system: ${welcomeMessage}`: ''}\n ${modOnlyMessage ? `system: ${modOnlyMessage}`: ''}\n` + const systemMessages = `${welcomeMessage ? `system: ${welcomeMessage}` : ''}\n ${modOnlyMessage ? `system: ${modOnlyMessage}` : ''}\n` const text = messages.reduce((acc, message) => { const date = new Date(message.createdTime); @@ -36,16 +30,16 @@ export const generateExportedMessages = (messages: Array, welcomeSettin let messageText = ''; switch (message.messageType) { - case MessageType.CHAT_CLEAR: + case ChatMessageType.CHAT_CLEAR: messageText = intl.formatMessage(intlMessages.chatClear); break; - case MessageType.TEXT: + case ChatMessageType.TEXT: default: messageText = htmlDecode(message.message); break; } return `${acc}${hourMin} ${userName}${messageText}\n`; - },welcomeMessage? systemMessages : ''); + }, welcomeMessage ? systemMessages : ''); return text; }; @@ -59,7 +53,5 @@ export const getDateString = (date = new Date()) => { return dateString; }; - // TODO: Make action using mutations export const clearPublicChatHistory = () => (makeCall('clearPublicChatHistory')); -