-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added pending & failed message (#363)
## Changes - Added pending and failed messages ticket: [AC-2609] [Sign in to Sendbird.webm](https://github.com/user-attachments/assets/d670a9ad-b006-448a-9157-56eceb0c7236) ## Additional Notes - Tested with localCacheEnabled false, and message input disabled false ## Checklist Before requesting a code review, please check the following: - [x] **[Required]** CI has passed all checks. - [x] **[Required]** A self-review has been conducted to ensure there are no minor mistakes. - [x] **[Required]** Unnecessary comments/debugging code have been removed. - [x] **[Required]** All requirements specified in the ticket have been accurately implemented. - [ ] Ensure the ticket has been updated with the sprint, status, and story points. [AC-2609]: https://sendbird.atlassian.net/browse/AC-2609?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Hyungu Kang | Airen <[email protected]>
- Loading branch information
Showing
4 changed files
with
51 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { css } from '@linaria/core'; | ||
import { SendableMessage } from '@sendbird/chat/lib/__definition'; | ||
import { SendingStatus } from '@sendbird/chat/message'; | ||
import { Locale } from 'date-fns'; | ||
import { useTheme } from 'styled-components'; | ||
|
||
import { DefaultSentTime } from './MessageComponent'; | ||
import { Icon } from '../foundation/components/Icon'; | ||
import { Loader } from '../foundation/components/Loader'; | ||
import { formatCreatedAtToAMPM } from '../utils/messageTimestamp'; | ||
|
||
interface MyMessageStatusProps { | ||
message: SendableMessage; | ||
dateLocale: Locale; | ||
} | ||
|
||
export default function MyMessageStatus(props: MyMessageStatusProps) { | ||
const { message, dateLocale } = props; | ||
const theme = useTheme(); | ||
|
||
switch (message.sendingStatus) { | ||
case SendingStatus.PENDING: | ||
return ( | ||
<Loader className={sendbirdLoader} size={16}> | ||
<Icon type={'spinner'} color={theme.bgColor.outgoingMessage} size={16} /> | ||
</Loader> | ||
); | ||
case SendingStatus.FAILED: | ||
return ( | ||
<div className={sendbirdLoader}> | ||
<Icon type={'error'} color={'error'} size={16} /> | ||
</div> | ||
); | ||
default: | ||
return <DefaultSentTime>{formatCreatedAtToAMPM(message.createdAt, dateLocale)}</DefaultSentTime>; | ||
} | ||
} | ||
|
||
const sendbirdLoader = css` | ||
margin-bottom: 2px; | ||
width: 16px; | ||
height: 16px; | ||
`; |
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