| 
									
										
										
										
											2022-03-04 16:14:52 -05:00
										 |  |  | // Copyright 2021-2022 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import React from 'react'; | 
					
						
							|  |  |  | import { connect } from 'react-redux'; | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  | import type { MenuItemConstructorOptions } from 'electron'; | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  | import type { MenuActionType } from '../../types/menu'; | 
					
						
							| 
									
										
										
										
											2021-08-31 15:58:39 -05:00
										 |  |  | import { App } from '../../components/App'; | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | import { SmartCallManager } from './CallManager'; | 
					
						
							| 
									
										
										
										
											2021-09-09 11:29:01 -05:00
										 |  |  | import { SmartCustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal'; | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | import { SmartGlobalModalContainer } from './GlobalModalContainer'; | 
					
						
							| 
									
										
										
										
											2022-06-16 15:12:50 -04:00
										 |  |  | import { SmartLeftPane } from './LeftPane'; | 
					
						
							| 
									
										
										
										
											2022-03-04 16:14:52 -05:00
										 |  |  | import { SmartStories } from './Stories'; | 
					
						
							| 
									
										
										
										
											2022-07-06 15:06:20 -04:00
										 |  |  | import { SmartStoryViewer } from './StoryViewer'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { StateType } from '../reducer'; | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   getIntl, | 
					
						
							|  |  |  |   getLocaleMessages, | 
					
						
							|  |  |  |   getTheme, | 
					
						
							|  |  |  |   getIsMainWindowMaximized, | 
					
						
							|  |  |  |   getIsMainWindowFullScreen, | 
					
						
							|  |  |  |   getMenuOptions, | 
					
						
							|  |  |  | } from '../selectors/user'; | 
					
						
							| 
									
										
										
										
											2022-07-06 15:06:20 -04:00
										 |  |  | import { | 
					
						
							| 
									
										
										
										
											2022-07-29 16:22:55 -04:00
										 |  |  |   hasSelectedStoryData, | 
					
						
							| 
									
										
										
										
											2022-07-06 15:06:20 -04:00
										 |  |  |   shouldShowStoriesView, | 
					
						
							|  |  |  | } from '../selectors/stories'; | 
					
						
							| 
									
										
										
										
											2022-06-20 11:26:31 -07:00
										 |  |  | import { getHideMenuBar } from '../selectors/items'; | 
					
						
							| 
									
										
										
										
											2021-09-09 11:29:01 -05:00
										 |  |  | import { getIsCustomizingPreferredReactions } from '../selectors/preferredReactions'; | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | import { mapDispatchToProps } from '../actions'; | 
					
						
							| 
									
										
										
										
											2022-07-28 20:10:07 -04:00
										 |  |  | import { ErrorBoundary } from '../../components/ErrorBoundary'; | 
					
						
							| 
									
										
										
										
											2022-10-17 10:58:49 -06:00
										 |  |  | import { ModalContainer } from '../../components/ModalContainer'; | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-31 15:58:39 -05:00
										 |  |  | const mapStateToProps = (state: StateType) => { | 
					
						
							| 
									
										
										
										
											2022-07-28 20:10:07 -04:00
										 |  |  |   const i18n = getIntl(state); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  |   return { | 
					
						
							|  |  |  |     ...state.app, | 
					
						
							| 
									
										
										
										
											2022-07-28 20:10:07 -04:00
										 |  |  |     i18n, | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  |     localeMessages: getLocaleMessages(state), | 
					
						
							| 
									
										
										
										
											2021-09-09 11:29:01 -05:00
										 |  |  |     isCustomizingPreferredReactions: getIsCustomizingPreferredReactions(state), | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  |     isMaximized: getIsMainWindowMaximized(state), | 
					
						
							|  |  |  |     isFullScreen: getIsMainWindowFullScreen(state), | 
					
						
							|  |  |  |     menuOptions: getMenuOptions(state), | 
					
						
							| 
									
										
										
										
											2022-07-05 09:44:53 -07:00
										 |  |  |     hasCustomTitleBar: window.SignalContext.OS.hasCustomTitleBar(), | 
					
						
							| 
									
										
										
										
											2022-06-20 11:26:31 -07:00
										 |  |  |     hideMenuBar: getHideMenuBar(state), | 
					
						
							| 
									
										
										
										
											2022-10-17 10:58:49 -06:00
										 |  |  |     renderCallManager: () => ( | 
					
						
							|  |  |  |       <ModalContainer className="module-calling__modal-container"> | 
					
						
							|  |  |  |         <SmartCallManager /> | 
					
						
							|  |  |  |       </ModalContainer> | 
					
						
							|  |  |  |     ), | 
					
						
							| 
									
										
										
										
											2021-09-09 11:29:01 -05:00
										 |  |  |     renderCustomizingPreferredReactionsModal: () => ( | 
					
						
							|  |  |  |       <SmartCustomizingPreferredReactionsModal /> | 
					
						
							|  |  |  |     ), | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  |     renderGlobalModalContainer: () => <SmartGlobalModalContainer />, | 
					
						
							| 
									
										
										
										
											2022-06-16 15:12:50 -04:00
										 |  |  |     renderLeftPane: () => <SmartLeftPane />, | 
					
						
							| 
									
										
										
										
											2022-03-04 16:14:52 -05:00
										 |  |  |     isShowingStoriesView: shouldShowStoriesView(state), | 
					
						
							| 
									
										
										
										
											2022-08-19 11:35:40 -07:00
										 |  |  |     renderStories: (closeView: () => unknown) => ( | 
					
						
							|  |  |  |       <ErrorBoundary name="App/renderStories" closeView={closeView}> | 
					
						
							| 
									
										
										
										
											2022-07-28 20:10:07 -04:00
										 |  |  |         <SmartStories /> | 
					
						
							|  |  |  |       </ErrorBoundary> | 
					
						
							|  |  |  |     ), | 
					
						
							| 
									
										
										
										
											2022-07-29 16:22:55 -04:00
										 |  |  |     hasSelectedStoryData: hasSelectedStoryData(state), | 
					
						
							| 
									
										
										
										
											2022-08-19 11:35:40 -07:00
										 |  |  |     renderStoryViewer: (closeView: () => unknown) => ( | 
					
						
							|  |  |  |       <ErrorBoundary name="App/renderStoryViewer" closeView={closeView}> | 
					
						
							| 
									
										
										
										
											2022-07-28 20:10:07 -04:00
										 |  |  |         <SmartStoryViewer /> | 
					
						
							|  |  |  |       </ErrorBoundary> | 
					
						
							|  |  |  |     ), | 
					
						
							| 
									
										
										
										
											2021-11-30 18:51:53 +01:00
										 |  |  |     requestVerification: ( | 
					
						
							|  |  |  |       type: 'sms' | 'voice', | 
					
						
							|  |  |  |       number: string, | 
					
						
							|  |  |  |       token: string | 
					
						
							|  |  |  |     ): Promise<void> => { | 
					
						
							|  |  |  |       const accountManager = window.getAccountManager(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (type === 'sms') { | 
					
						
							|  |  |  |         return accountManager.requestSMSVerification(number, token); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return accountManager.requestVoiceVerification(number, token); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     registerSingleDevice: (number: string, code: string): Promise<void> => { | 
					
						
							|  |  |  |       return window.getAccountManager().registerSingleDevice(number, code); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-06-16 15:12:50 -04:00
										 |  |  |     selectedConversationId: state.conversations.selectedConversationId, | 
					
						
							|  |  |  |     selectedMessage: state.conversations.selectedMessage, | 
					
						
							| 
									
										
										
										
											2022-11-09 12:18:03 -08:00
										 |  |  |     selectedMessageSource: state.conversations.selectedMessageSource, | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  |     theme: getTheme(state), | 
					
						
							| 
									
										
										
										
											2022-06-08 15:00:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     executeMenuRole: (role: MenuItemConstructorOptions['role']): void => { | 
					
						
							|  |  |  |       window.SignalContext.executeMenuRole(role); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     executeMenuAction: (action: MenuActionType): void => { | 
					
						
							|  |  |  |       window.SignalContext.executeMenuAction(action); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     titleBarDoubleClick: (): void => { | 
					
						
							|  |  |  |       window.titleBarDoubleClick(); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-09-26 10:24:52 -06:00
										 |  |  |     toast: state.toast.toast, | 
					
						
							| 
									
										
										
										
											2021-06-17 17:15:09 -04:00
										 |  |  |   }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const smart = connect(mapStateToProps, mapDispatchToProps); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const SmartApp = smart(App); |