signal-desktop/ts/state/smart/GlobalModalContainer.tsx

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-05-28 16:15:17 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { GlobalModalContainer } from '../../components/GlobalModalContainer';
import { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import { SmartChatColorPicker } from './ChatColorPicker';
2021-07-19 19:26:06 +00:00
import { SmartProfileEditorModal } from './ProfileEditorModal';
// Workaround: A react component's required properties are filtering up through connect()
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31363
/* eslint-disable @typescript-eslint/no-explicit-any */
const FilteredSmartProfileEditorModal = SmartProfileEditorModal as any;
/* eslint-enable @typescript-eslint/no-explicit-any */
2021-05-28 16:15:17 +00:00
2021-06-03 21:34:36 +00:00
function renderChatColorPicker(): JSX.Element {
return <SmartChatColorPicker />;
2021-05-28 16:15:17 +00:00
}
2021-07-19 19:26:06 +00:00
function renderProfileEditor(): JSX.Element {
return <FilteredSmartProfileEditorModal />;
}
2021-05-28 16:15:17 +00:00
const mapStateToProps = (state: StateType) => {
return {
...state.globalModals,
i18n: getIntl(state),
renderChatColorPicker,
2021-07-19 19:26:06 +00:00
renderProfileEditor,
2021-05-28 16:15:17 +00:00
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartGlobalModalContainer = smart(GlobalModalContainer);