2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-05-27 21:37:06 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
|
|
|
|
|
|
|
import { ConversationHero } from '../../components/conversation/ConversationHero';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-11-02 23:01:13 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2022-07-22 00:44:35 +00:00
|
|
|
import { getHasStoriesSelector } from '../selectors/stories';
|
2022-11-09 02:38:19 +00:00
|
|
|
import { isSignalConversation } from '../../util/isSignalConversation';
|
2020-05-27 21:37:06 +00:00
|
|
|
|
|
|
|
type ExternalProps = {
|
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
|
|
|
const { id } = props;
|
|
|
|
|
|
|
|
const conversation = state.conversations.conversationLookup[id];
|
|
|
|
|
|
|
|
if (!conversation) {
|
|
|
|
throw new Error(`Did not find conversation ${id} in state!`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
i18n: getIntl(state),
|
2020-07-29 23:20:05 +00:00
|
|
|
...conversation,
|
2020-05-27 21:37:06 +00:00
|
|
|
conversationType: conversation.type,
|
2022-07-22 00:44:35 +00:00
|
|
|
hasStories: getHasStoriesSelector(state)(id),
|
2021-11-02 23:01:13 +00:00
|
|
|
badge: getPreferredBadgeSelector(state)(conversation.badges),
|
2022-11-09 02:38:19 +00:00
|
|
|
isSignalConversation: isSignalConversation(conversation),
|
2021-11-02 23:01:13 +00:00
|
|
|
theme: getTheme(state),
|
2020-05-27 21:37:06 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartHeroRow = smart(ConversationHero);
|