2022-03-04 21:14:52 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
2021-06-17 21:15:09 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2022-06-08 22:00:32 +00:00
|
|
|
import type { MenuItemConstructorOptions } from 'electron';
|
2021-06-17 21:15:09 +00:00
|
|
|
|
2022-06-08 22:00:32 +00:00
|
|
|
import type { MenuActionType } from '../../types/menu';
|
2021-08-31 20:58:39 +00:00
|
|
|
import { App } from '../../components/App';
|
2021-06-17 21:15:09 +00:00
|
|
|
import { SmartCallManager } from './CallManager';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { SmartCustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal';
|
2021-06-17 21:15:09 +00:00
|
|
|
import { SmartGlobalModalContainer } from './GlobalModalContainer';
|
2022-06-16 19:12:50 +00:00
|
|
|
import { SmartLeftPane } from './LeftPane';
|
2021-08-31 20:58:39 +00:00
|
|
|
import { SmartSafetyNumberViewer } from './SafetyNumberViewer';
|
2022-03-04 21:14:52 +00:00
|
|
|
import { SmartStories } from './Stories';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-11-17 21:58:34 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2022-06-08 22:00:32 +00:00
|
|
|
import {
|
|
|
|
getIntl,
|
|
|
|
getLocaleMessages,
|
|
|
|
getTheme,
|
|
|
|
getIsMainWindowMaximized,
|
|
|
|
getIsMainWindowFullScreen,
|
|
|
|
getMenuOptions,
|
|
|
|
getPlatform,
|
|
|
|
} from '../selectors/user';
|
2022-03-04 21:14:52 +00:00
|
|
|
import { shouldShowStoriesView } from '../selectors/stories';
|
2022-06-20 18:26:31 +00:00
|
|
|
import { getHideMenuBar } from '../selectors/items';
|
2022-02-16 18:36:21 +00:00
|
|
|
import { getConversationsStoppingSend } from '../selectors/conversations';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { getIsCustomizingPreferredReactions } from '../selectors/preferredReactions';
|
2021-06-17 21:15:09 +00:00
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-08-31 20:58:39 +00:00
|
|
|
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog';
|
2021-06-17 21:15:09 +00:00
|
|
|
|
2021-08-31 20:58:39 +00:00
|
|
|
const mapStateToProps = (state: StateType) => {
|
2021-06-17 21:15:09 +00:00
|
|
|
return {
|
|
|
|
...state.app,
|
2022-02-16 18:36:21 +00:00
|
|
|
conversationsStoppingSend: getConversationsStoppingSend(state),
|
2021-11-17 21:58:34 +00:00
|
|
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
2021-08-31 20:58:39 +00:00
|
|
|
i18n: getIntl(state),
|
2022-06-08 22:00:32 +00:00
|
|
|
localeMessages: getLocaleMessages(state),
|
2021-09-09 16:29:01 +00:00
|
|
|
isCustomizingPreferredReactions: getIsCustomizingPreferredReactions(state),
|
2022-06-08 22:00:32 +00:00
|
|
|
isMaximized: getIsMainWindowMaximized(state),
|
|
|
|
isFullScreen: getIsMainWindowFullScreen(state),
|
|
|
|
menuOptions: getMenuOptions(state),
|
|
|
|
platform: getPlatform(state),
|
2022-06-15 18:21:03 +00:00
|
|
|
isWindows11: window.SignalContext.OS.isWindows11(),
|
2022-06-20 18:26:31 +00:00
|
|
|
hideMenuBar: getHideMenuBar(state),
|
2021-06-17 21:15:09 +00:00
|
|
|
renderCallManager: () => <SmartCallManager />,
|
2021-09-09 16:29:01 +00:00
|
|
|
renderCustomizingPreferredReactionsModal: () => (
|
|
|
|
<SmartCustomizingPreferredReactionsModal />
|
|
|
|
),
|
2021-06-17 21:15:09 +00:00
|
|
|
renderGlobalModalContainer: () => <SmartGlobalModalContainer />,
|
2022-06-16 19:12:50 +00:00
|
|
|
renderLeftPane: () => <SmartLeftPane />,
|
2021-08-31 20:58:39 +00:00
|
|
|
renderSafetyNumber: (props: SafetyNumberProps) => (
|
|
|
|
<SmartSafetyNumberViewer {...props} />
|
|
|
|
),
|
2022-03-04 21:14:52 +00:00
|
|
|
isShowingStoriesView: shouldShowStoriesView(state),
|
|
|
|
renderStories: () => <SmartStories />,
|
2021-11-30 17:51:53 +00: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 19:12:50 +00:00
|
|
|
selectedConversationId: state.conversations.selectedConversationId,
|
|
|
|
selectedMessage: state.conversations.selectedMessage,
|
2021-06-17 21:15:09 +00:00
|
|
|
theme: getTheme(state),
|
2022-06-08 22:00:32 +00:00
|
|
|
|
|
|
|
executeMenuRole: (role: MenuItemConstructorOptions['role']): void => {
|
|
|
|
window.SignalContext.executeMenuRole(role);
|
|
|
|
},
|
|
|
|
executeMenuAction: (action: MenuActionType): void => {
|
|
|
|
window.SignalContext.executeMenuAction(action);
|
|
|
|
},
|
|
|
|
titleBarDoubleClick: (): void => {
|
|
|
|
window.titleBarDoubleClick();
|
|
|
|
},
|
2021-06-17 21:15:09 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartApp = smart(App);
|