Timestamp: Eliminate 'Invalid date' from potential output
This commit is contained in:
parent
60f61c804b
commit
95976b10e7
2 changed files with 30 additions and 1 deletions
|
@ -184,3 +184,28 @@ We only show one line.
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Missing data
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<div>
|
||||||
|
<ConversationListItem
|
||||||
|
name="John"
|
||||||
|
lastUpdated={null}
|
||||||
|
lastMessage={{
|
||||||
|
text: 'Missing last updated',
|
||||||
|
}}
|
||||||
|
onClick={() => console.log('onClick')}
|
||||||
|
i18n={util.i18n}
|
||||||
|
/>
|
||||||
|
<ConversationListItem
|
||||||
|
name="Missing message"
|
||||||
|
lastUpdated={Date.now() - 5 * 60 * 1000}
|
||||||
|
lastMessage={{
|
||||||
|
text: null,
|
||||||
|
}}
|
||||||
|
onClick={() => console.log('onClick')}
|
||||||
|
i18n={util.i18n}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { formatRelativeTime } from '../../util/formatRelativeTime';
|
||||||
import { Localizer } from '../../types/Util';
|
import { Localizer } from '../../types/Util';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
timestamp: number;
|
timestamp: number | null;
|
||||||
extended: boolean;
|
extended: boolean;
|
||||||
module?: string;
|
module?: string;
|
||||||
withImageNoCaption?: boolean;
|
withImageNoCaption?: boolean;
|
||||||
|
@ -52,6 +52,10 @@ export class Timestamp extends React.Component<Props> {
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const moduleName = module || 'module-timestamp';
|
const moduleName = module || 'module-timestamp';
|
||||||
|
|
||||||
|
if (timestamp === null || timestamp === undefined) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
Loading…
Add table
Reference in a new issue