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

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2019 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';
import {
getIntl,
getRegionCode,
getTheme,
getUserConversationId,
getUserNumber,
} from '../selectors/user';
2022-01-27 22:12:26 +00:00
import { getMe } from '../selectors/conversations';
2022-03-04 21:14:52 +00:00
import { getStoriesEnabled } from '../selectors/items';
2023-02-07 19:33:04 +00:00
import {
getStoriesNotificationCount,
getHasAnyFailedStorySends,
} from '../selectors/stories';
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 {
2022-03-04 21:14:52 +00:00
areStoriesEnabled: getStoriesEnabled(state),
hasPendingUpdate: Boolean(state.updates.didSnooze),
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),
...me,
badge: getPreferredBadgeSelector(state)(me.badges),
theme: getTheme(state),
2019-01-14 21:49:58 +00:00
i18n: getIntl(state),
2023-02-07 19:33:04 +00:00
hasFailedStorySends: getHasAnyFailedStorySends(state),
unreadStoriesCount: getStoriesNotificationCount(state),
2019-01-14 21:49:58 +00:00
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartMainHeader = smart(MainHeader);