| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2021 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import * as React from 'react'; | 
					
						
							|  |  |  | import { action } from '@storybook/addon-actions'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 20:30:08 -04:00
										 |  |  | import { setupI18n } from '../../util/setupI18n'; | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | import enMessages from '../../../_locales/en/messages.json'; | 
					
						
							|  |  |  | import { CallMode } from '../../types/Calling'; | 
					
						
							|  |  |  | import { CallingNotification } from './CallingNotification'; | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  | import type { CallingNotificationType } from '../../util/callingNotification'; | 
					
						
							| 
									
										
										
										
											2023-01-12 15:29:07 -08:00
										 |  |  | import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | const i18n = setupI18n('en', enMessages); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | export default { | 
					
						
							|  |  |  |   title: 'Components/Conversation/CallingNotification', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | const getCommonProps = () => ({ | 
					
						
							|  |  |  |   conversationId: 'fake-conversation-id', | 
					
						
							|  |  |  |   i18n, | 
					
						
							| 
									
										
										
										
											2022-03-28 15:55:12 -07:00
										 |  |  |   isNextItemCallingNotification: false, | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  |   messageId: 'fake-message-id', | 
					
						
							| 
									
										
										
										
											2022-03-03 14:23:10 -06:00
										 |  |  |   now: Date.now(), | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  |   returnToActiveCall: action('returnToActiveCall'), | 
					
						
							|  |  |  |   startCallingLobby: action('startCallingLobby'), | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | /* | 
					
						
							|  |  |  | <CallingNotification | 
					
						
							|  |  |  |   {...getCommonProps()} | 
					
						
							|  |  |  |   acceptedTime={wasDeclined ? undefined : 1618894800000} | 
					
						
							|  |  |  |   callMode={CallMode.Direct} | 
					
						
							|  |  |  |   endedTime={1618894800000} | 
					
						
							|  |  |  |   wasDeclined={wasDeclined} | 
					
						
							|  |  |  |   wasIncoming={wasIncoming} | 
					
						
							|  |  |  |   wasVideoCall={wasVideoCall} | 
					
						
							|  |  |  | /> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function AcceptedIncomingAudioCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={1618894800000} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined={false} | 
					
						
							|  |  |  |       wasIncoming | 
					
						
							|  |  |  |       wasVideoCall={false} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function AcceptedIncomingVideoCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={1618894800000} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined={false} | 
					
						
							|  |  |  |       wasIncoming | 
					
						
							|  |  |  |       wasVideoCall | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function DeclinedIncomingAudioCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={undefined} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined | 
					
						
							|  |  |  |       wasIncoming | 
					
						
							|  |  |  |       wasVideoCall={false} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function DeclinedIncomingVideoCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={undefined} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined | 
					
						
							|  |  |  |       wasIncoming | 
					
						
							|  |  |  |       wasVideoCall | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function AcceptedOutgoingAudioCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={1618894800000} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined={false} | 
					
						
							|  |  |  |       wasIncoming={false} | 
					
						
							|  |  |  |       wasVideoCall={false} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function AcceptedOutgoingVideoCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={1618894800000} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined={false} | 
					
						
							|  |  |  |       wasIncoming={false} | 
					
						
							|  |  |  |       wasVideoCall | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function DeclinedOutgoingAudioCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={undefined} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined | 
					
						
							|  |  |  |       wasIncoming={false} | 
					
						
							|  |  |  |       wasVideoCall={false} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function DeclinedOutgoingVideoCall(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       acceptedTime={undefined} | 
					
						
							|  |  |  |       callMode={CallMode.Direct} | 
					
						
							|  |  |  |       endedTime={1618894800000} | 
					
						
							|  |  |  |       wasDeclined | 
					
						
							|  |  |  |       wasIncoming={false} | 
					
						
							|  |  |  |       wasVideoCall | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function TwoIncomingDirectCallsBackToBack(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  |   const call1: CallingNotificationType = { | 
					
						
							|  |  |  |     callMode: CallMode.Direct, | 
					
						
							|  |  |  |     wasIncoming: true, | 
					
						
							|  |  |  |     wasVideoCall: true, | 
					
						
							|  |  |  |     wasDeclined: false, | 
					
						
							|  |  |  |     acceptedTime: 1618894800000, | 
					
						
							|  |  |  |     endedTime: 1618894800000, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   const call2: CallingNotificationType = { | 
					
						
							|  |  |  |     callMode: CallMode.Direct, | 
					
						
							|  |  |  |     wasIncoming: true, | 
					
						
							|  |  |  |     wasVideoCall: false, | 
					
						
							|  |  |  |     wasDeclined: false, | 
					
						
							|  |  |  |     endedTime: 1618894800000, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <> | 
					
						
							|  |  |  |       <CallingNotification | 
					
						
							|  |  |  |         {...getCommonProps()} | 
					
						
							|  |  |  |         {...call1} | 
					
						
							| 
									
										
										
										
											2022-03-28 15:55:12 -07:00
										 |  |  |         isNextItemCallingNotification | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  |       /> | 
					
						
							|  |  |  |       <CallingNotification {...getCommonProps()} {...call2} /> | 
					
						
							|  |  |  |     </> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | TwoIncomingDirectCallsBackToBack.story = { | 
					
						
							|  |  |  |   name: 'Two incoming direct calls back-to-back', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function TwoOutgoingDirectCallsBackToBack(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  |   const call1: CallingNotificationType = { | 
					
						
							|  |  |  |     callMode: CallMode.Direct, | 
					
						
							|  |  |  |     wasIncoming: false, | 
					
						
							|  |  |  |     wasVideoCall: true, | 
					
						
							|  |  |  |     wasDeclined: false, | 
					
						
							|  |  |  |     acceptedTime: 1618894800000, | 
					
						
							|  |  |  |     endedTime: 1618894800000, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   const call2: CallingNotificationType = { | 
					
						
							|  |  |  |     callMode: CallMode.Direct, | 
					
						
							|  |  |  |     wasIncoming: false, | 
					
						
							|  |  |  |     wasVideoCall: false, | 
					
						
							|  |  |  |     wasDeclined: false, | 
					
						
							|  |  |  |     endedTime: 1618894800000, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <> | 
					
						
							|  |  |  |       <CallingNotification | 
					
						
							|  |  |  |         {...getCommonProps()} | 
					
						
							|  |  |  |         {...call1} | 
					
						
							| 
									
										
										
										
											2022-03-28 15:55:12 -07:00
										 |  |  |         isNextItemCallingNotification | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  |       /> | 
					
						
							|  |  |  |       <CallingNotification {...getCommonProps()} {...call2} /> | 
					
						
							|  |  |  |     </> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-09-10 18:59:41 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | TwoOutgoingDirectCallsBackToBack.story = { | 
					
						
							|  |  |  |   name: 'Two outgoing direct calls back-to-back', | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallByUnknown(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							|  |  |  |       creator={undefined} | 
					
						
							|  |  |  |       deviceCount={15} | 
					
						
							|  |  |  |       ended={false} | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallByYou(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							| 
									
										
										
										
											2023-01-12 15:29:07 -08:00
										 |  |  |       creator={getDefaultConversation({ isMe: true, title: 'Alicia' })} | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  |       deviceCount={15} | 
					
						
							|  |  |  |       ended={false} | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallBySomeone(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							| 
									
										
										
										
											2023-01-12 15:29:07 -08:00
										 |  |  |       creator={getDefaultConversation({ isMe: false, title: 'Alicia' })} | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  |       deviceCount={15} | 
					
						
							|  |  |  |       ended={false} | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallStartedBySomeoneWithALongName(): JSX.Element { | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  |   const longName = '😤🪐🦆'.repeat(50); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							| 
									
										
										
										
											2023-01-12 15:29:07 -08:00
										 |  |  |       creator={getDefaultConversation({ | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  |         title: longName, | 
					
						
							| 
									
										
										
										
											2023-01-12 15:29:07 -08:00
										 |  |  |       })} | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  |       deviceCount={15} | 
					
						
							|  |  |  |       ended={false} | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | GroupCallStartedBySomeoneWithALongName.story = { | 
					
						
							|  |  |  |   name: 'Group call: started by someone with a long name', | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-09-02 16:23:27 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallActiveCallFull(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							|  |  |  |       deviceCount={16} | 
					
						
							|  |  |  |       ended={false} | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-07-23 16:34:48 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | GroupCallActiveCallFull.story = { | 
					
						
							|  |  |  |   name: 'Group call: active, call full', | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function GroupCallEnded(): JSX.Element { | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <CallingNotification | 
					
						
							|  |  |  |       {...getCommonProps()} | 
					
						
							|  |  |  |       callMode={CallMode.Group} | 
					
						
							|  |  |  |       deviceCount={0} | 
					
						
							|  |  |  |       ended | 
					
						
							|  |  |  |       maxDevices={16} | 
					
						
							|  |  |  |       startedTime={1618894800000} | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-06-06 20:48:02 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | GroupCallEnded.story = { | 
					
						
							|  |  |  |   name: 'Group call: ended', | 
					
						
							|  |  |  | }; |