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

50 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-11-01 18:43:02 +00:00
// Copyright 2019-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2019-01-14 21:49:58 +00:00
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { MainHeader } from '../../components/MainHeader';
import type { StateType } from '../reducer';
2019-01-14 21:49:58 +00:00
import { getPreferredBadgeSelector } from '../selectors/badges';
2019-08-09 23:12:29 +00:00
import {
getQuery,
2021-11-01 18:43:02 +00:00
getSearchConversation,
2019-11-07 21:36:16 +00:00
getStartSearchCounter,
2019-08-09 23:12:29 +00:00
} from '../selectors/search';
import {
getIntl,
getRegionCode,
getTheme,
getUserConversationId,
getUserNumber,
getUserUuid,
} from '../selectors/user';
import { getMe, getSelectedConversation } from '../selectors/conversations';
2019-01-14 21:49:58 +00:00
const mapStateToProps = (state: StateType) => {
const me = getMe(state);
2019-01-14 21:49:58 +00:00
return {
disabled: state.network.challengeStatus !== 'idle',
hasPendingUpdate: Boolean(state.updates.didSnooze),
2019-01-14 21:49:58 +00:00
searchTerm: getQuery(state),
2021-11-01 18:43:02 +00:00
searchConversation: getSearchConversation(state),
selectedConversation: getSelectedConversation(state),
2019-11-07 21:36:16 +00:00
startSearchCounter: getStartSearchCounter(state),
2019-01-14 21:49:58 +00:00
regionCode: getRegionCode(state),
ourConversationId: getUserConversationId(state),
2019-01-14 21:49:58 +00:00
ourNumber: getUserNumber(state),
ourUuid: getUserUuid(state),
...me,
badge: getPreferredBadgeSelector(state)(me.badges),
theme: getTheme(state),
2019-01-14 21:49:58 +00:00
i18n: getIntl(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartMainHeader = smart(MainHeader);