| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2019 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  | import { SystemMessage } from './SystemMessage'; | 
					
						
							| 
									
										
										
										
											2021-08-26 16:51:55 -04:00
										 |  |  | import { Button, ButtonSize, ButtonVariant } from '../Button'; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | import { ContactName } from './ContactName'; | 
					
						
							|  |  |  | import { Intl } from '../Intl'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { LocalizerType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2022-12-19 17:04:47 -08:00
										 |  |  | import { openLinkInWebBrowser } from '../../util/openLinkInWebBrowser'; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | export type ContactType = { | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  |   id: string; | 
					
						
							| 
									
										
										
										
											2020-07-23 18:35:32 -07:00
										 |  |  |   phoneNumber?: string; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  |   profileName?: string; | 
					
						
							| 
									
										
										
										
											2020-07-23 18:35:32 -07:00
										 |  |  |   title: string; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  |   name?: string; | 
					
						
							|  |  |  |   isMe: boolean; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type PropsData = { | 
					
						
							|  |  |  |   canProcessNow: boolean; | 
					
						
							|  |  |  |   contact: ContactType; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-31 15:42:01 -07:00
										 |  |  | type PropsHousekeeping = { | 
					
						
							|  |  |  |   i18n: LocalizerType; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-19 17:04:47 -08:00
										 |  |  | export type Props = PropsData & PropsHousekeeping; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function UnsupportedMessage({ | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   canProcessNow, | 
					
						
							|  |  |  |   contact, | 
					
						
							|  |  |  |   i18n, | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | }: Props): JSX.Element { | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   const { isMe } = contact; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   const otherStringId = canProcessNow | 
					
						
							|  |  |  |     ? 'Message--unsupported-message-ask-to-resend' | 
					
						
							|  |  |  |     : 'Message--unsupported-message'; | 
					
						
							|  |  |  |   const meStringId = canProcessNow | 
					
						
							|  |  |  |     ? 'Message--from-me-unsupported-message-ask-to-resend' | 
					
						
							|  |  |  |     : 'Message--from-me-unsupported-message'; | 
					
						
							|  |  |  |   const stringId = isMe ? meStringId : otherStringId; | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |   const icon = canProcessNow ? 'unsupported--can-process' : 'unsupported'; | 
					
						
							| 
									
										
										
										
											2019-06-10 14:40:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |     <SystemMessage | 
					
						
							|  |  |  |       icon={icon} | 
					
						
							|  |  |  |       contents={ | 
					
						
							| 
									
										
										
										
											2023-01-05 14:43:33 -08:00
										 |  |  |         // eslint-disable-next-line local-rules/valid-i18n-keys
 | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |         <Intl | 
					
						
							|  |  |  |           id={stringId} | 
					
						
							|  |  |  |           components={[ | 
					
						
							|  |  |  |             <span | 
					
						
							|  |  |  |               key="external-1" | 
					
						
							|  |  |  |               className="module-unsupported-message__contact" | 
					
						
							|  |  |  |             > | 
					
						
							|  |  |  |               <ContactName | 
					
						
							|  |  |  |                 title={contact.title} | 
					
						
							|  |  |  |                 module="module-unsupported-message__contact" | 
					
						
							|  |  |  |               /> | 
					
						
							|  |  |  |             </span>, | 
					
						
							|  |  |  |           ]} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |         /> | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |       } | 
					
						
							|  |  |  |       button={ | 
					
						
							|  |  |  |         canProcessNow ? undefined : ( | 
					
						
							|  |  |  |           <div className="SystemMessage__line"> | 
					
						
							|  |  |  |             <Button | 
					
						
							|  |  |  |               onClick={() => { | 
					
						
							| 
									
										
										
										
											2022-12-19 17:04:47 -08:00
										 |  |  |                 openLinkInWebBrowser('https://signal.org/download'); | 
					
						
							| 
									
										
										
										
											2021-09-07 14:55:03 -05:00
										 |  |  |               }} | 
					
						
							|  |  |  |               size={ButtonSize.Small} | 
					
						
							|  |  |  |               variant={ButtonVariant.SystemMessage} | 
					
						
							|  |  |  |             > | 
					
						
							|  |  |  |               {i18n('Message--update-signal')} | 
					
						
							|  |  |  |             </Button> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     /> | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |