| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2018 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  | import type { ReactElement } from 'react'; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | import classNames from 'classnames'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { TypingAnimation } from './TypingAnimation'; | 
					
						
							|  |  |  | import { Avatar } from '../Avatar'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  | import type { LocalizerType, ThemeType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { ConversationType } from '../../state/ducks/conversations'; | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  | import type { BadgeType } from '../../badges/types'; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  | export type Props = Pick< | 
					
						
							|  |  |  |   ConversationType, | 
					
						
							|  |  |  |   | 'acceptedMessageRequest' | 
					
						
							|  |  |  |   | 'avatarPath' | 
					
						
							|  |  |  |   | 'color' | 
					
						
							|  |  |  |   | 'isMe' | 
					
						
							|  |  |  |   | 'phoneNumber' | 
					
						
							|  |  |  |   | 'profileName' | 
					
						
							|  |  |  |   | 'sharedGroupNames' | 
					
						
							|  |  |  |   | 'title' | 
					
						
							|  |  |  | > & { | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  |   badge: undefined | BadgeType; | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  |   conversationType: 'group' | 'direct'; | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |   i18n: LocalizerType; | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  |   theme: ThemeType; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  | export function TypingBubble({ | 
					
						
							|  |  |  |   acceptedMessageRequest, | 
					
						
							|  |  |  |   avatarPath, | 
					
						
							|  |  |  |   badge, | 
					
						
							|  |  |  |   color, | 
					
						
							|  |  |  |   conversationType, | 
					
						
							|  |  |  |   i18n, | 
					
						
							|  |  |  |   isMe, | 
					
						
							|  |  |  |   phoneNumber, | 
					
						
							|  |  |  |   profileName, | 
					
						
							|  |  |  |   sharedGroupNames, | 
					
						
							|  |  |  |   theme, | 
					
						
							|  |  |  |   title, | 
					
						
							|  |  |  | }: Props): ReactElement { | 
					
						
							|  |  |  |   const isGroup = conversationType === 'group'; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  |   return ( | 
					
						
							|  |  |  |     <div | 
					
						
							|  |  |  |       className={classNames( | 
					
						
							|  |  |  |         'module-message', | 
					
						
							|  |  |  |         'module-message--incoming', | 
					
						
							|  |  |  |         isGroup ? 'module-message--group' : null | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       {isGroup && ( | 
					
						
							|  |  |  |         <div className="module-message__author-avatar-container"> | 
					
						
							|  |  |  |           <Avatar | 
					
						
							|  |  |  |             acceptedMessageRequest={acceptedMessageRequest} | 
					
						
							|  |  |  |             avatarPath={avatarPath} | 
					
						
							|  |  |  |             badge={badge} | 
					
						
							|  |  |  |             color={color} | 
					
						
							|  |  |  |             conversationType="direct" | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							|  |  |  |             isMe={isMe} | 
					
						
							|  |  |  |             phoneNumber={phoneNumber} | 
					
						
							|  |  |  |             profileName={profileName} | 
					
						
							|  |  |  |             theme={theme} | 
					
						
							|  |  |  |             title={title} | 
					
						
							|  |  |  |             sharedGroupNames={sharedGroupNames} | 
					
						
							|  |  |  |             size={28} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       )} | 
					
						
							|  |  |  |       <div className="module-message__container-outer"> | 
					
						
							|  |  |  |         <div | 
					
						
							|  |  |  |           className={classNames( | 
					
						
							|  |  |  |             'module-message__container', | 
					
						
							|  |  |  |             'module-message__container--incoming' | 
					
						
							|  |  |  |           )} | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           <div className="module-message__typing-container"> | 
					
						
							|  |  |  |             <TypingAnimation color="light" i18n={i18n} /> | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |           </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2021-11-15 14:01:58 -06:00
										 |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | } |