From 95976b10e7c591ccef2fa6d7ce073047357413ca Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 18 Jul 2018 08:14:34 -0700 Subject: [PATCH] Timestamp: Eliminate 'Invalid date' from potential output --- ts/components/ConversationListItem.md | 25 ++++++++++++++++++++++++ ts/components/conversation/Timestamp.tsx | 6 +++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ts/components/ConversationListItem.md b/ts/components/ConversationListItem.md index 67cc729b9..996042c45 100644 --- a/ts/components/ConversationListItem.md +++ b/ts/components/ConversationListItem.md @@ -184,3 +184,28 @@ We only show one line. /> ``` + +#### Missing data + +```jsx +
+ console.log('onClick')} + i18n={util.i18n} + /> + console.log('onClick')} + i18n={util.i18n} + /> +
+``` diff --git a/ts/components/conversation/Timestamp.tsx b/ts/components/conversation/Timestamp.tsx index 5d75721f6..1d66760b4 100644 --- a/ts/components/conversation/Timestamp.tsx +++ b/ts/components/conversation/Timestamp.tsx @@ -7,7 +7,7 @@ import { formatRelativeTime } from '../../util/formatRelativeTime'; import { Localizer } from '../../types/Util'; interface Props { - timestamp: number; + timestamp: number | null; extended: boolean; module?: string; withImageNoCaption?: boolean; @@ -52,6 +52,10 @@ export class Timestamp extends React.Component { } = this.props; const moduleName = module || 'module-timestamp'; + if (timestamp === null || timestamp === undefined) { + return null; + } + return (