From f9ee030b6525103ae7924d71b41ea5d1b990dcfc Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 14 Jun 2024 11:24:36 +0200 Subject: [PATCH] refactor: remove timestampTranslationKey prop --- src/components/DateSeparator/DateSeparator.tsx | 5 +---- src/components/EventComponent/EventComponent.tsx | 13 ++----------- src/components/Message/MessageTimestamp.tsx | 2 -- src/components/Message/Timestamp.tsx | 16 ++-------------- 4 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/components/DateSeparator/DateSeparator.tsx b/src/components/DateSeparator/DateSeparator.tsx index 988cdf74e..7a7d36d2f 100644 --- a/src/components/DateSeparator/DateSeparator.tsx +++ b/src/components/DateSeparator/DateSeparator.tsx @@ -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; }; @@ -22,7 +20,6 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => { date: messageCreatedAt, formatDate, position = 'right', - timestampTranslationKey = 'timestamp/DateSeparator', unread, ...restTimestampFormatterOptions } = props; @@ -36,7 +33,7 @@ const UnMemoizedDateSeparator = (props: DateSeparatorProps) => { messageCreatedAt, t, tDateTimeParser, - timestampTranslationKey, + timestampTranslationKey: 'timestamp/DateSeparator', }); return ( diff --git a/src/components/EventComponent/EventComponent.tsx b/src/components/EventComponent/EventComponent.tsx index 47581db65..9b6b7e891 100644 --- a/src/components/EventComponent/EventComponent.tsx +++ b/src/components/EventComponent/EventComponent.tsx @@ -16,8 +16,6 @@ export type EventComponentProps< message: StreamMessage; /** 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; - /* Lookup key in the language corresponding translations sheet to perform date formatting */ - timestampTranslationKey?: string; }; /** @@ -28,14 +26,7 @@ const UnMemoizedEventComponent = < >( props: EventComponentProps, ) => { - 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; @@ -57,7 +48,7 @@ const UnMemoizedEventComponent = < calendarFormats, format, t, - timestampTranslationKey, + timestampTranslationKey: 'timestamp/SystemMessage', })} diff --git a/src/components/Message/MessageTimestamp.tsx b/src/components/Message/MessageTimestamp.tsx index 48a8b91f5..2ae7c0b46 100644 --- a/src/components/Message/MessageTimestamp.tsx +++ b/src/components/Message/MessageTimestamp.tsx @@ -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; - /* Lookup key in the language corresponding translations sheet to perform date formatting */ - timestampTranslationKey?: string; }; const UnMemoizedMessageTimestamp = < diff --git a/src/components/Message/Timestamp.tsx b/src/components/Message/Timestamp.tsx index a16913088..75d08104e 100644 --- a/src/components/Message/Timestamp.tsx +++ b/src/components/Message/Timestamp.tsx @@ -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'; @@ -23,7 +21,6 @@ export function Timestamp(props: TimestampProps) { customClass, format = defaultTimestampFormat, timestamp, - timestampTranslationKey = 'timestamp/Timestamp', } = props; const { formatDate } = useMessageContext('MessageTimestamp'); @@ -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) {