From 2706b6b618e52afd79a5b37ad95d0697bf2775c9 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 22 Oct 2023 13:36:34 +0200 Subject: [PATCH] fix: date formatting in previous note view --- .../backend/src/server/api/endpoints/notes/versions.ts | 2 +- packages/frontend/src/components/SkOldNoteWindow.vue | 3 ++- packages/frontend/src/scripts/get-note-versions-menu.ts | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/versions.ts b/packages/backend/src/server/api/endpoints/notes/versions.ts index e6831f3208..18a68110f7 100644 --- a/packages/backend/src/server/api/endpoints/notes/versions.ts +++ b/packages/backend/src/server/api/endpoints/notes/versions.ts @@ -50,7 +50,7 @@ export default class extends Endpoint { // eslint- for (const edit of edits) { editArray.push({ - updatedAt: new Date(edit.updatedAt).toLocaleString('UTC', { hour: 'numeric', minute: 'numeric', second: 'numeric', year: 'numeric', month: 'short', day: 'numeric' }), + updatedAt: edit.updatedAt, text: edit.oldText, }); } diff --git a/packages/frontend/src/components/SkOldNoteWindow.vue b/packages/frontend/src/components/SkOldNoteWindow.vue index bd0b87bf6c..f3dfa4858e 100644 --- a/packages/frontend/src/components/SkOldNoteWindow.vue +++ b/packages/frontend/src/components/SkOldNoteWindow.vue @@ -2,7 +2,7 @@
@@ -92,6 +92,7 @@ import { extractUrlFromMfm } from '@/scripts/extract-url-from-mfm.js'; import { $i } from '@/account.js'; import { i18n } from '@/i18n.js'; import { deepClone } from '@/scripts/clone.js'; +import { dateTimeFormat } from '@/scripts/intl-const.js'; const props = defineProps<{ note: Misskey.entities.Note; diff --git a/packages/frontend/src/scripts/get-note-versions-menu.ts b/packages/frontend/src/scripts/get-note-versions-menu.ts index 4191920638..599ae9c89f 100644 --- a/packages/frontend/src/scripts/get-note-versions-menu.ts +++ b/packages/frontend/src/scripts/get-note-versions-menu.ts @@ -3,6 +3,7 @@ import * as Misskey from 'misskey-js'; import { i18n } from '@/i18n.js'; import * as os from '@/os.js'; import { MenuItem } from '@/types/menu.js'; +import { dateTimeFormat } from './intl-const.js'; export async function getNoteVersionsMenu(props: { note: Misskey.entities.Note; @@ -35,9 +36,13 @@ export async function getNoteVersionsMenu(props: { await statePromise.then((versions) => { for (const edit of versions) { + const _time = edit.updatedAt == null ? NaN : + typeof edit.updatedAt === 'number' ? edit.updatedAt : + (edit.updatedAt instanceof Date ? edit.updatedAt : new Date(edit.updatedAt)).getTime(); + menu.push({ icon: 'ph-pencil ph-bold ph-lg', - text: `${edit.updatedAt}`, + text: dateTimeFormat.format(_time), action: () => openVersion(edit), }); }