Apply suggestions from review
This commit is contained in:
parent
41bc2b6481
commit
b91309be82
13 changed files with 169 additions and 61 deletions
|
@ -1,7 +1,23 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { exportOptions, exportTypes } from "./exportUtils";
|
||||
import { IExportOptions, exportTypes } from "./exportUtils";
|
||||
import { decryptFile } from "../DecryptFile";
|
||||
import { mediaFromContent } from "../../customisations/Media";
|
||||
import { formatFullDateNoDay } from "../../DateUtils";
|
||||
|
@ -23,7 +39,7 @@ export default abstract class Exporter {
|
|||
protected constructor(
|
||||
protected room: Room,
|
||||
protected exportType: exportTypes,
|
||||
protected exportOptions: exportOptions,
|
||||
protected exportOptions: IExportOptions,
|
||||
protected exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
this.cancelled = false;
|
||||
|
@ -53,6 +69,8 @@ export default abstract class Exporter {
|
|||
protected async downloadZIP(): Promise<any> {
|
||||
const filename = `matrix-export-${formatFullDateNoDay(new Date())}.zip`;
|
||||
|
||||
console.log(this.files, this.files.length);
|
||||
|
||||
const zip = new JSZip();
|
||||
// Create a writable stream to the directory
|
||||
if (!this.cancelled) this.updateProgress("Generating a ZIP");
|
||||
|
@ -62,7 +80,7 @@ export default abstract class Exporter {
|
|||
|
||||
const content = await zip.generateAsync({ type: "blob" });
|
||||
|
||||
await saveAs(content, filename);
|
||||
saveAs(content, filename);
|
||||
}
|
||||
|
||||
protected cleanUp(): string {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import React, { MutableRefObject } from "react";
|
||||
import Exporter from "./Exporter";
|
||||
import { mediaFromMxc } from "../../customisations/Media";
|
||||
|
@ -18,7 +34,7 @@ import exportCSS from "./exportCSS";
|
|||
import exportJS from "./exportJS";
|
||||
import exportIcons from "./exportIcons";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { exportOptions } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||
|
||||
export default class HTMLExporter extends Exporter {
|
||||
|
@ -30,7 +46,7 @@ export default class HTMLExporter extends Exporter {
|
|||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportOptions: exportOptions,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
super(room, exportType, exportOptions, exportProgressRef);
|
||||
|
|
|
@ -1,10 +1,26 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import Exporter from "./Exporter";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
import { formatFullDateNoDay, formatFullDateNoDayNoTime } from "../../DateUtils";
|
||||
import { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { exportOptions } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||
import { MutableRefObject } from "react";
|
||||
|
||||
|
@ -15,7 +31,7 @@ export default class JSONExporter extends Exporter {
|
|||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportOptions: exportOptions,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
super(room, exportType, exportOptions, exportProgressRef);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import Exporter from "./Exporter";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
|
@ -5,7 +21,7 @@ import { formatFullDateNoDay } from "../../DateUtils";
|
|||
import { _t } from "../../languageHandler";
|
||||
import { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
||||
import { exportTypes } from "./exportUtils";
|
||||
import { exportOptions } from "./exportUtils";
|
||||
import { IExportOptions } from "./exportUtils";
|
||||
import { textForEvent } from "../../TextForEvent";
|
||||
import { MutableRefObject } from "react";
|
||||
|
||||
|
@ -16,7 +32,7 @@ export default class PlainTextExporter extends Exporter {
|
|||
constructor(
|
||||
room: Room,
|
||||
exportType: exportTypes,
|
||||
exportOptions: exportOptions,
|
||||
exportOptions: IExportOptions,
|
||||
exportProgressRef: MutableRefObject<HTMLParagraphElement>,
|
||||
) {
|
||||
super(room, exportType, exportOptions, exportProgressRef);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-len */
|
||||
const lightCSS = `@charset "utf-8";
|
||||
.hljs-addition {
|
||||
|
@ -25405,6 +25421,11 @@ a.mx_reply_anchor:hover{
|
|||
}
|
||||
}
|
||||
|
||||
.mx_ReplyThread_Export {
|
||||
margin-top: -5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.mx_RedactedBody img.mx_export_trash_icon {
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
Copyright 2018-2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
import { _t } from "../../languageHandler";
|
||||
|
||||
export enum exportFormats {
|
||||
|
@ -37,7 +53,7 @@ export const textForType = (type: string): string => {
|
|||
}
|
||||
};
|
||||
|
||||
export interface exportOptions {
|
||||
export interface IExportOptions {
|
||||
startDate?: number;
|
||||
numberOfMessages?: number;
|
||||
attachmentsIncluded: boolean;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue