Skip to content

Commit

Permalink
refactor: remove timestampTranslationKey prop
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Jun 14, 2024
1 parent daa4d4c commit f9ee030
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 31 deletions.
5 changes: 1 addition & 4 deletions src/components/DateSeparator/DateSeparator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export type DateSeparatorProps = TimestampFormatterOptions & {
formatDate?: (date: Date) => string;
/** Set the position of the date in the separator, options are 'left', 'center', 'right', @default right */
position?: 'left' | 'center' | 'right';
/* Lookup key in the language corresponding translations sheet to perform date formatting */
timestampTranslationKey?: string;
/** If following messages are not new */
unread?: boolean;
};
Expand All @@ -22,7 +20,6 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => {
date: messageCreatedAt,
formatDate,
position = 'right',
timestampTranslationKey = 'timestamp/DateSeparator',
unread,
...restTimestampFormatterOptions
} = props;
Expand All @@ -36,7 +33,7 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => {
messageCreatedAt,
t,
tDateTimeParser,
timestampTranslationKey,
timestampTranslationKey: 'timestamp/DateSeparator',
});

return (
Expand Down
13 changes: 2 additions & 11 deletions src/components/EventComponent/EventComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export type EventComponentProps<
message: StreamMessage<StreamChatGenerics>;
/** Custom UI component to display user avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
Avatar?: React.ComponentType<AvatarProps>;
/* Lookup key in the language corresponding translations sheet to perform date formatting */
timestampTranslationKey?: string;
};

/**
Expand All @@ -28,14 +26,7 @@ const UnMemoizedEventComponent = <
>(
props: EventComponentProps<StreamChatGenerics>,
) => {
const {
calendar,
calendarFormats,
format = 'dddd L',
Avatar = DefaultAvatar,
message,
timestampTranslationKey = 'timestamp/SystemMessage',
} = props;
const { calendar, calendarFormats, format = 'dddd L', Avatar = DefaultAvatar, message } = props;

const { t, tDateTimeParser } = useTranslationContext('EventComponent');
const { created_at = '', event, text, type } = message;
Expand All @@ -57,7 +48,7 @@ const UnMemoizedEventComponent = <
calendarFormats,
format,
t,
timestampTranslationKey,
timestampTranslationKey: 'timestamp/SystemMessage',
})}
</strong>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/components/Message/MessageTimestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export type MessageTimestampProps<
customClass?: string;
/* The `StreamChat` message object, which provides necessary data to the underlying UI components (overrides the value from `MessageContext`) */
message?: StreamMessage<StreamChatGenerics>;
/* Lookup key in the language corresponding translations sheet to perform date formatting */
timestampTranslationKey?: string;
};

const UnMemoizedMessageTimestamp = <
Expand Down
16 changes: 2 additions & 14 deletions src/components/Message/Timestamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export interface TimestampProps extends TimestampFormatterOptions {
customClass?: string;
/* Timestamp to display */
timestamp?: Date | string;
/* Lookup key in the language corresponding translations sheet to perform date formatting */
timestampTranslationKey?: string;
}

export const defaultTimestampFormat = 'h:mmA';
Expand All @@ -23,7 +21,6 @@ export function Timestamp(props: TimestampProps) {
customClass,
format = defaultTimestampFormat,
timestamp,
timestampTranslationKey = 'timestamp/Timestamp',
} = props;

const { formatDate } = useMessageContext('MessageTimestamp');
Expand All @@ -41,18 +38,9 @@ export function Timestamp(props: TimestampProps) {
messageCreatedAt: normalizedTimestamp,
t,
tDateTimeParser,
timestampTranslationKey,
timestampTranslationKey: 'timestamp/Timestamp',
}),
[
calendar,
calendarFormats,
format,
formatDate,
normalizedTimestamp,
t,
tDateTimeParser,
timestampTranslationKey,
],
[calendar, calendarFormats, format, formatDate, normalizedTimestamp, t, tDateTimeParser],
);

if (!when) {
Expand Down

0 comments on commit f9ee030

Please sign in to comment.