2021-07-26 23:40:27 +05:30
|
|
|
/*
|
2021-07-27 19:29:22 +05:30
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
2021-07-26 23:40:27 +05:30
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-06-26 13:04:10 +05:30
|
|
|
import { _t } from "../../languageHandler";
|
2021-05-22 11:32:55 +05:30
|
|
|
|
2021-08-13 08:30:50 +05:30
|
|
|
export enum ExportFormat {
|
2021-08-13 08:59:14 +05:30
|
|
|
Html = "Html",
|
|
|
|
|
PlainText = "PlainText",
|
|
|
|
|
Json = "Json",
|
2021-05-24 18:01:09 +05:30
|
|
|
}
|
2021-05-22 11:32:55 +05:30
|
|
|
|
2021-08-13 08:30:50 +05:30
|
|
|
export enum ExportType {
|
2021-08-13 08:59:14 +05:30
|
|
|
Timeline = "Timeline",
|
|
|
|
|
Beginning = "Beginning",
|
|
|
|
|
LastNMessages = "LastNMessages",
|
2021-07-27 00:00:52 +05:30
|
|
|
// START_DATE = "START_DATE",
|
2021-06-26 21:53:50 +05:30
|
|
|
}
|
|
|
|
|
|
2021-08-13 08:59:14 +05:30
|
|
|
export const textForFormat = (format: ExportFormat): string => {
|
2021-06-26 21:53:50 +05:30
|
|
|
switch (format) {
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportFormat.Html:
|
2021-06-26 21:53:50 +05:30
|
|
|
return _t("HTML");
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportFormat.Json:
|
2021-06-26 21:53:50 +05:30
|
|
|
return _t("JSON");
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportFormat.PlainText:
|
2021-06-26 21:53:50 +05:30
|
|
|
return _t("Plain Text");
|
2021-08-03 14:36:21 +05:30
|
|
|
default:
|
|
|
|
|
throw new Error("Unknown format");
|
2021-06-26 21:53:50 +05:30
|
|
|
}
|
2021-06-30 14:08:22 +05:30
|
|
|
};
|
2021-06-26 21:53:50 +05:30
|
|
|
|
2021-08-13 08:59:14 +05:30
|
|
|
export const textForType = (type: ExportType): string => {
|
2021-06-26 21:53:50 +05:30
|
|
|
switch (type) {
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportType.Beginning:
|
2021-06-26 21:53:50 +05:30
|
|
|
return _t("From the beginning");
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportType.LastNMessages:
|
2021-07-26 00:09:59 +05:30
|
|
|
return _t("Specify a number of messages");
|
2021-08-13 08:30:50 +05:30
|
|
|
case ExportType.Timeline:
|
2021-06-26 21:53:50 +05:30
|
|
|
return _t("Current Timeline");
|
2021-08-03 14:36:21 +05:30
|
|
|
default:
|
|
|
|
|
throw new Error("Unknown type: " + type);
|
2021-06-26 21:53:50 +05:30
|
|
|
// case exportTypes.START_DATE:
|
|
|
|
|
// return _t("From a specific date");
|
|
|
|
|
}
|
2021-06-30 14:08:22 +05:30
|
|
|
};
|
2021-05-22 11:32:55 +05:30
|
|
|
|
2021-07-26 23:40:27 +05:30
|
|
|
export interface IExportOptions {
|
2021-08-03 14:36:21 +05:30
|
|
|
// startDate?: number;
|
2021-06-11 12:04:05 +05:30
|
|
|
numberOfMessages?: number;
|
2021-06-14 11:08:17 +05:30
|
|
|
attachmentsIncluded: boolean;
|
2021-06-15 16:41:31 +05:30
|
|
|
maxSize: number;
|
2021-06-11 12:04:05 +05:30
|
|
|
}
|