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

35 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-01-14 21:49:58 +00:00
import React from 'react';
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { LeftPane } from '../../components/LeftPane';
import { StateType } from '../reducer';
2019-03-12 00:20:16 +00:00
import { getSearchResults, isSearching } from '../selectors/search';
2019-01-14 21:49:58 +00:00
import { getIntl } from '../selectors/user';
2019-03-12 00:20:16 +00:00
import { getLeftPaneLists, getShowArchived } from '../selectors/conversations';
2019-01-14 21:49:58 +00:00
import { SmartMainHeader } from './MainHeader';
// Workaround: A react component's required properties are filtering up through connect()
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31363
const FilteredSmartMainHeader = SmartMainHeader as any;
const mapStateToProps = (state: StateType) => {
const showSearch = isSearching(state);
2019-03-12 00:20:16 +00:00
const lists = showSearch ? undefined : getLeftPaneLists(state);
const searchResults = showSearch ? getSearchResults(state) : undefined;
2019-01-14 21:49:58 +00:00
return {
2019-03-12 00:20:16 +00:00
...lists,
searchResults,
showArchived: getShowArchived(state),
2019-01-14 21:49:58 +00:00
i18n: getIntl(state),
renderMainHeader: () => <FilteredSmartMainHeader />,
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartLeftPane = smart(LeftPane);