From b1fac73f7568bb8ee516d50ad826b73dffe16a60 Mon Sep 17 00:00:00 2001 From: Patrick O'Sullivan Date: Thu, 12 Oct 2023 09:27:51 -0500 Subject: [PATCH] notebook: don't attempt to get a time from an empty string, use sent value where possible --- ui/src/diary/DiaryComment.tsx | 3 +-- ui/src/diary/DiaryNote.tsx | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ui/src/diary/DiaryComment.tsx b/ui/src/diary/DiaryComment.tsx index 29d6543d68..c4205e91fb 100644 --- a/ui/src/diary/DiaryComment.tsx +++ b/ui/src/diary/DiaryComment.tsx @@ -1,7 +1,6 @@ /* eslint-disable react/no-unused-prop-types */ import React from 'react'; import { BigInteger } from 'big-integer'; -import { daToUnix } from '@urbit/api'; import { format } from 'date-fns'; import Author from '@/chat/ChatMessage/Author'; // eslint-disable-next-line import/no-cycle @@ -32,7 +31,7 @@ const DiaryComment = React.memo< ) => { const { cork, memo } = quip; const flag = useChannelFlag(); - const unix = new Date(daToUnix(time)); + const unix = new Date(quip.memo.sent); const normalizedContent: ChatStory = { ...memo.content, block: memo.content.block.filter( diff --git a/ui/src/diary/DiaryNote.tsx b/ui/src/diary/DiaryNote.tsx index 56a4279323..d39c0eadbe 100644 --- a/ui/src/diary/DiaryNote.tsx +++ b/ui/src/diary/DiaryNote.tsx @@ -200,15 +200,18 @@ export default function DiaryNote({ title }: ViewProps) { const { quips } = note.seal; const quipArray = Array.from(quips).reverse(); // natural reading order const canWrite = canWriteChannel(perms, vessel, group?.bloc); - const groupedQuips = setNewDays( - groupQuips(noteId, quipArray, brief).sort(([a], [b]) => { - if (sort === 'asc') { - return a.localeCompare(b); - } + const groupedQuips = + noteId !== '' + ? setNewDays( + groupQuips(noteId, quipArray, brief).sort(([a], [b]) => { + if (sort === 'asc') { + return a.localeCompare(b); + } - return b.localeCompare(a); - }) - ); + return b.localeCompare(a); + }) + ) + : []; return (