| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  | // Copyright 2018-2021 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | import classNames from 'classnames'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { TypingAnimation } from './TypingAnimation'; | 
					
						
							|  |  |  | import { Avatar } from '../Avatar'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-13 13:53:45 -07:00
										 |  |  | import { LocalizerType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  | import { ConversationType } from '../../state/ducks/conversations'; | 
					
						
							| 
									
										
										
										
											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' | 
					
						
							|  |  |  |   | 'name' | 
					
						
							|  |  |  |   | 'phoneNumber' | 
					
						
							|  |  |  |   | 'profileName' | 
					
						
							|  |  |  |   | 'sharedGroupNames' | 
					
						
							|  |  |  |   | 'title' | 
					
						
							|  |  |  | > & { | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  |   conversationType: 'group' | 'direct'; | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |   i18n: LocalizerType; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  | export class TypingBubble extends React.PureComponent<Props> { | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   public renderAvatar(): JSX.Element | null { | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |     const { | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |       acceptedMessageRequest, | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |       avatarPath, | 
					
						
							|  |  |  |       color, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |       conversationType, | 
					
						
							|  |  |  |       i18n, | 
					
						
							|  |  |  |       isMe, | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |       name, | 
					
						
							|  |  |  |       phoneNumber, | 
					
						
							|  |  |  |       profileName, | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |       sharedGroupNames, | 
					
						
							| 
									
										
										
										
											2020-07-23 18:35:32 -07:00
										 |  |  |       title, | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |     } = this.props; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (conversationType !== 'group') { | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |       return null; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return ( | 
					
						
							| 
									
										
										
										
											2021-01-27 21:41:41 -06:00
										 |  |  |       <div className="module-message__author-avatar-container"> | 
					
						
							|  |  |  |         <div className="module-message__author-avatar"> | 
					
						
							|  |  |  |           <Avatar | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |             acceptedMessageRequest={acceptedMessageRequest} | 
					
						
							| 
									
										
										
										
											2021-01-27 21:41:41 -06:00
										 |  |  |             avatarPath={avatarPath} | 
					
						
							|  |  |  |             color={color} | 
					
						
							|  |  |  |             conversationType="direct" | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |             isMe={isMe} | 
					
						
							| 
									
										
										
										
											2021-01-27 21:41:41 -06:00
										 |  |  |             name={name} | 
					
						
							|  |  |  |             phoneNumber={phoneNumber} | 
					
						
							|  |  |  |             profileName={profileName} | 
					
						
							|  |  |  |             title={title} | 
					
						
							| 
									
										
										
										
											2021-05-07 17:21:10 -05:00
										 |  |  |             sharedGroupNames={sharedGroupNames} | 
					
						
							| 
									
										
										
										
											2021-01-27 21:41:41 -06:00
										 |  |  |             size={28} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   public render(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  |     const { i18n, color, conversationType } = this.props; | 
					
						
							|  |  |  |     const isGroup = conversationType === 'group'; | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return ( | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  |       <div | 
					
						
							|  |  |  |         className={classNames( | 
					
						
							|  |  |  |           'module-message', | 
					
						
							|  |  |  |           'module-message--incoming', | 
					
						
							|  |  |  |           isGroup ? 'module-message--group' : null | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2021-01-27 21:41:41 -06:00
										 |  |  |         {this.renderAvatar()} | 
					
						
							|  |  |  |         <div className="module-message__container-outer"> | 
					
						
							|  |  |  |           <div | 
					
						
							|  |  |  |             className={classNames( | 
					
						
							|  |  |  |               'module-message__container', | 
					
						
							|  |  |  |               'module-message__container--incoming', | 
					
						
							|  |  |  |               `module-message__container--incoming-${color}` | 
					
						
							|  |  |  |             )} | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <div className="module-message__typing-container"> | 
					
						
							|  |  |  |               <TypingAnimation color="light" i18n={i18n} /> | 
					
						
							|  |  |  |             </div> | 
					
						
							| 
									
										
										
										
											2018-11-14 11:10:32 -08:00
										 |  |  |           </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |