Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Exported filename ISO date format #9142

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ export function formatFullDateNoDay(date: Date) {
});
}

export function formatFullDateNoDayISO(date: Date) {
return date.toISOString();
}

export function formatFullDateNoDayNoTime(date: Date) {
return (
date.getFullYear() +
Expand Down
4 changes: 2 additions & 2 deletions src/utils/exportUtils/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { MatrixClientPeg } from "../../MatrixClientPeg";
import { ExportType, IExportOptions } from "./exportUtils";
import { decryptFile } from "../DecryptFile";
import { mediaFromContent } from "../../customisations/Media";
import { formatFullDateNoDay } from "../../DateUtils";
import { formatFullDateNoDay, formatFullDateNoDayISO } from "../../DateUtils";
import { isVoiceMessage } from "../EventUtils";
import { IMediaEventContent } from "../../customisations/models/IMediaEventContent";
import { _t } from "../../languageHandler";
Expand Down Expand Up @@ -77,7 +77,7 @@ export default abstract class Exporter {

protected async downloadZIP(): Promise<string | void> {
const brand = SdkConfig.get().brand;
const filenameWithoutExt = `${brand} - Chat Export - ${formatFullDateNoDay(new Date())}`;
const filenameWithoutExt = `${brand} - ${this.room.name} - Chat Export -${formatFullDateNoDayISO(new Date())}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need to consider the room name having invalid characters in it?

applies to later on as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turt2live there is another PR which does that, I believe: #7992

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't land this code at the moment without that code, given the safety risk we'd be taking on. It feels like it might have been split up too much?

const filename = `${filenameWithoutExt}.zip`;
const { default: JSZip } = await import('jszip');

Expand Down
4 changes: 2 additions & 2 deletions src/utils/exportUtils/JSONExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event";
import { logger } from "matrix-js-sdk/src/logger";

import Exporter from "./Exporter";
import { formatFullDateNoDay, formatFullDateNoDayNoTime } from "../../DateUtils";
import { formatFullDateNoDayISO, formatFullDateNoDayNoTime } from "../../DateUtils";
import { ExportType, IExportOptions } from "./exportUtils";
import { _t } from "../../languageHandler";
import { haveRendererForEvent } from "../../events/EventTileFactory";
Expand Down Expand Up @@ -108,7 +108,7 @@ export default class JSONExporter extends Exporter {
this.addFile("export.json", new Blob([text]));
await this.downloadZIP();
} else {
const fileName = `matrix-export-${formatFullDateNoDay(new Date())}.json`;
const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.json`;
this.downloadPlainText(fileName, text);
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/exportUtils/PlainTextExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { logger } from "matrix-js-sdk/src/logger";
import React from "react";

import Exporter from "./Exporter";
import { formatFullDateNoDay } from "../../DateUtils";
import { formatFullDateNoDayISO } from "../../DateUtils";
import { _t } from "../../languageHandler";
import { ExportType, IExportOptions } from "./exportUtils";
import { textForEvent } from "../../TextForEvent";
Expand Down Expand Up @@ -137,7 +137,7 @@ export default class PlainTextExporter extends Exporter {
this.addFile("export.txt", new Blob([text]));
await this.downloadZIP();
} else {
const fileName = `matrix-export-${formatFullDateNoDay(new Date())}.txt`;
const fileName = `matrix-${this.room.name}-export-${formatFullDateNoDayISO(new Date())}.txt`;
this.downloadPlainText(fileName, text);
}

Expand Down