From d49099baebb81b5a4f3e110f071cddb2cd09d2ff Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 22 Oct 2023 19:19:44 +0200 Subject: [PATCH] upd: add additional checks --- packages/backend/src/server/api/endpoints/notes/versions.ts | 6 +++--- packages/frontend/src/components/SkOldNoteWindow.vue | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/versions.ts b/packages/backend/src/server/api/endpoints/notes/versions.ts index d236cea64..416fddcb7 100644 --- a/packages/backend/src/server/api/endpoints/notes/versions.ts +++ b/packages/backend/src/server/api/endpoints/notes/versions.ts @@ -50,13 +50,13 @@ export default class extends Endpoint { // eslint- for (const edit of edits) { editArray.push({ - oldDate: edit.oldDate, + oldDate: edit.oldDate as Date | null ?? null, updatedAt: edit.updatedAt, - text: edit.oldText, + text: edit.oldText ?? edit.newText ?? null, }); } - editArray = editArray.sort((a, b) => { return new Date(b.oldDate).getTime() - new Date(a.oldDate).getTime(); }); + editArray = editArray.sort((a, b) => { return new Date(b.oldDate ?? b.updatedAt).getTime() - new Date(a.oldDate ?? a.updatedAt).getTime(); }); return editArray; }); diff --git a/packages/frontend/src/components/SkOldNoteWindow.vue b/packages/frontend/src/components/SkOldNoteWindow.vue index f3dfa4858..522348f6b 100644 --- a/packages/frontend/src/components/SkOldNoteWindow.vue +++ b/packages/frontend/src/components/SkOldNoteWindow.vue @@ -120,7 +120,7 @@ if (noteViewInterruptors.length > 0) { } const replaceContent = () => { - note.text = props.oldText; + props.oldText ? note.text = props.oldText : undefined; note.createdAt = props.updatedAt; }; replaceContent();