<MessageTimestamp>: make timestamp prop required

This commit is contained in:
Evan Hahn 2022-03-03 22:35:59 -06:00 committed by GitHub
parent 26100ea562
commit a3b1b696db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View file

@ -41,7 +41,7 @@ const times = (): Array<[string, number]> => [
const createProps = (overrideProps: Partial<Props> = {}): Props => ({ const createProps = (overrideProps: Partial<Props> = {}): Props => ({
i18n, i18n,
timestamp: overrideProps.timestamp, timestamp: overrideProps.timestamp || Date.now(),
now: Date.now(), now: Date.now(),
module: text('module', ''), module: text('module', ''),
withImageNoCaption: boolean('withImageNoCaption', false), withImageNoCaption: boolean('withImageNoCaption', false),

View file

@ -12,7 +12,7 @@ import { Time } from '../Time';
export type Props = { export type Props = {
now: number; now: number;
timestamp?: number; timestamp: number;
module?: string; module?: string;
withImageNoCaption?: boolean; withImageNoCaption?: boolean;
withSticker?: boolean; withSticker?: boolean;
@ -30,13 +30,9 @@ export function MessageTimestamp({
withImageNoCaption, withImageNoCaption,
withSticker, withSticker,
withTapToViewExpired, withTapToViewExpired,
}: Readonly<Props>): null | ReactElement { }: Readonly<Props>): ReactElement {
const moduleName = module || 'module-timestamp'; const moduleName = module || 'module-timestamp';
if (timestamp === null || timestamp === undefined) {
return null;
}
return ( return (
<Time <Time
className={classNames( className={classNames(