2021-02-23 20:34:28 +00:00
|
|
|
// Copyright 2019-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { CSSProperties } from 'react';
|
2019-01-14 21:49:58 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2019-08-09 00:46:49 +00:00
|
|
|
import { mapDispatchToProps } from '../actions';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2019-01-14 21:49:58 +00:00
|
|
|
|
2021-02-23 20:34:28 +00:00
|
|
|
import { MessageSearchResult } from '../../components/conversationList/MessageSearchResult';
|
2021-11-17 21:11:21 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2019-08-09 00:46:49 +00:00
|
|
|
import { getMessageSearchResultSelector } from '../selectors/search';
|
2019-01-14 21:49:58 +00:00
|
|
|
|
|
|
|
type SmartProps = {
|
|
|
|
id: string;
|
2021-09-13 02:36:41 +00:00
|
|
|
style?: CSSProperties;
|
2019-01-14 21:49:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps(state: StateType, ourProps: SmartProps) {
|
2021-02-23 20:34:28 +00:00
|
|
|
const { id, style } = ourProps;
|
2019-01-14 21:49:58 +00:00
|
|
|
|
2019-08-09 00:46:49 +00:00
|
|
|
const props = getMessageSearchResultSelector(state)(id);
|
2021-07-07 16:37:55 +00:00
|
|
|
if (!props) {
|
|
|
|
throw new Error('SmartMessageSearchResult: no message was found');
|
|
|
|
}
|
2019-08-09 00:46:49 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
...props,
|
2021-11-17 21:11:21 +00:00
|
|
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
2019-08-09 00:46:49 +00:00
|
|
|
i18n: getIntl(state),
|
2021-02-23 20:34:28 +00:00
|
|
|
style,
|
2021-11-17 21:11:21 +00:00
|
|
|
theme: getTheme(state),
|
2019-08-09 00:46:49 +00:00
|
|
|
};
|
2019-01-14 21:49:58 +00:00
|
|
|
}
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartMessageSearchResult = smart(MessageSearchResult);
|