You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { connect } from 'react-redux';
|
|
import { mapDispatchToProps } from '../actions';
|
|
import { LeftPane } from '../../components/LeftPane';
|
|
import { StateType } from '../reducer';
|
|
|
|
import { getQuery, getSearchResults, isSearching } from '../selectors/search';
|
|
import {
|
|
getIntl,
|
|
getIsSecondaryDevice,
|
|
getRegionCode,
|
|
getUserNumber,
|
|
} from '../selectors/user';
|
|
import { getLeftPaneLists } from '../selectors/conversations';
|
|
|
|
// Workaround: A react component's required properties are filtering up through connect()
|
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31363
|
|
|
|
const mapStateToProps = (state: StateType) => {
|
|
const showSearch = isSearching(state);
|
|
|
|
const leftPaneList = getLeftPaneLists(state);
|
|
const lists = showSearch ? undefined : leftPaneList;
|
|
const searchResults = showSearch ? getSearchResults(state) : undefined;
|
|
return {
|
|
...lists,
|
|
searchTerm: getQuery(state),
|
|
regionCode: getRegionCode(state),
|
|
ourNumber: getUserNumber(state),
|
|
isSecondaryDevice: getIsSecondaryDevice(state),
|
|
searchResults,
|
|
i18n: getIntl(state),
|
|
unreadMessageCount: leftPaneList.unreadCount,
|
|
theme: state.theme,
|
|
focusedSection: state.section.focusedSection,
|
|
};
|
|
};
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
export const SmartLeftPane = smart(LeftPane);
|