From edfc8af6cf93a1a6884c244e965434cc0e7aeef2 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Fri, 13 Aug 2021 08:30:50 +0530 Subject: [PATCH] Apply PR Suggestions --- src/components/views/dialogs/ExportDialog.tsx | 32 +-- src/components/views/messages/MFileBody.tsx | 182 +++++++++--------- src/utils/exportUtils/Exporter.ts | 17 +- src/utils/exportUtils/HtmlExport.tsx | 4 +- src/utils/exportUtils/JSONExport.ts | 10 +- src/utils/exportUtils/PlainTextExport.ts | 4 +- src/utils/exportUtils/exportUtils.ts | 28 +-- test/utils/export-test.tsx | 10 +- 8 files changed, 143 insertions(+), 144 deletions(-) diff --git a/src/components/views/dialogs/ExportDialog.tsx b/src/components/views/dialogs/ExportDialog.tsx index 5ebe6ed7c5..6116faf1e1 100644 --- a/src/components/views/dialogs/ExportDialog.tsx +++ b/src/components/views/dialogs/ExportDialog.tsx @@ -24,8 +24,8 @@ import Field from "../elements/Field"; import StyledRadioGroup from "../elements/StyledRadioGroup"; import StyledCheckbox from "../elements/StyledCheckbox"; import { - ExportFormats, - ExportTypes, + ExportFormat, + ExportType, textForFormat, textForType, } from "../../../utils/exportUtils/exportUtils"; @@ -42,8 +42,8 @@ interface IProps extends IDialogProps { } const ExportDialog: React.FC = ({ room, onFinished }) => { - const [exportFormat, setExportFormat] = useState(ExportFormats.HTML); - const [exportType, setExportType] = useState(ExportTypes.TIMELINE); + const [exportFormat, setExportFormat] = useState(ExportFormat.Html); + const [exportType, setExportType] = useState(ExportType.Timeline); const [includeAttachments, setAttachments] = useState(false); const [isExporting, setExporting] = useState(false); const [numberOfMessages, setNumberOfMessages] = useState(100); @@ -70,31 +70,31 @@ const ExportDialog: React.FC = ({ room, onFinished }) => { maxSize: sizeLimit * 1024 * 1024, }; switch (exportFormat) { - case ExportFormats.HTML: + case ExportFormat.Html: setExporter( new HTMLExporter( room, - ExportTypes[exportType], + ExportType[exportType], exportOptions, exportProgressRef, ), ); break; - case ExportFormats.JSON: + case ExportFormat.Json: setExporter( new JSONExporter( room, - ExportTypes[exportType], + ExportType[exportType], exportOptions, exportProgressRef, ), ); break; - case ExportFormats.PLAIN_TEXT: + case ExportFormat.PlainText: setExporter( new PlainTextExporter( room, - ExportTypes[exportType], + ExportType[exportType], exportOptions, exportProgressRef, ), @@ -114,7 +114,7 @@ const ExportDialog: React.FC = ({ room, onFinished }) => { sizeLimitRef.current.validate({ focused: true }); return; } - if (exportType === ExportTypes.LAST_N_MESSAGES) { + if (exportType === ExportType.LastNMessages) { const isValidNumberOfMessages = await messageCountRef.current.validate({ focused: false }); if (!isValidNumberOfMessages) { @@ -202,12 +202,12 @@ const ExportDialog: React.FC = ({ room, onFinished }) => { }); }; - const exportFormatOptions = Object.keys(ExportFormats).map((format) => ({ + const exportFormatOptions = Object.keys(ExportFormat).map((format) => ({ value: format, label: textForFormat(format), })); - const exportTypeOptions = Object.keys(ExportTypes).map((type) => { + const exportTypeOptions = Object.keys(ExportType).map((type) => { return (