-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add message edited timestamp (#2304)
### π― Goal π GetStream/stream-chat-css#275 π GetStream/stream-chat-js#1248 Adds a new collapsible section in message metadata that shows the last time message text was updated. Also, clearly labels edited messages. ### π¨ UI Changes See GetStream/stream-chat-css#275 ### To-Do - [x] Bump LLC - [x] Bump styles - [x] Translations
- Loading branch information
1 parent
024ba6c
commit 5633614
Showing
26 changed files
with
261 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
import { useComponentContext, useMessageContext, useTranslationContext } from '../../context'; | ||
import { Timestamp as DefaultTimestamp } from './Timestamp'; | ||
import { isMessageEdited } from './utils'; | ||
|
||
import type { DefaultStreamChatGenerics } from '../../types'; | ||
import type { MessageTimestampProps } from './MessageTimestamp'; | ||
|
||
export type MessageEditedTimestampProps< | ||
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics | ||
> = MessageTimestampProps<StreamChatGenerics> & { | ||
open: boolean; | ||
}; | ||
|
||
export function MessageEditedTimestamp< | ||
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics | ||
>({ | ||
message: propMessage, | ||
open, | ||
...timestampProps | ||
}: MessageEditedTimestampProps<StreamChatGenerics>) { | ||
const { t } = useTranslationContext('MessageEditedTimestamp'); | ||
const { message: contextMessage } = useMessageContext<StreamChatGenerics>( | ||
'MessageEditedTimestamp', | ||
); | ||
const { Timestamp = DefaultTimestamp } = useComponentContext('MessageEditedTimestamp'); | ||
const message = propMessage || contextMessage; | ||
|
||
if (!isMessageEdited(message)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
'str-chat__message-edited-timestamp', | ||
open | ||
? 'str-chat__message-edited-timestamp--open' | ||
: 'str-chat__message-edited-timestamp--collapsed', | ||
)} | ||
data-testid='message-edited-timestamp' | ||
> | ||
{t<string>('Edited')}{' '} | ||
<Timestamp timestamp={message.message_text_updated_at} {...timestampProps} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.