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

36 lines
980 B
TypeScript
Raw Normal View History

// Copyright 2019-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { CSSProperties } from 'react';
2019-01-14 21:49:58 +00:00
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
2019-01-14 21:49:58 +00:00
import { StateType } from '../reducer';
import { MessageSearchResult } from '../../components/conversationList/MessageSearchResult';
import { getIntl } from '../selectors/user';
import { getMessageSearchResultSelector } from '../selectors/search';
2019-01-14 21:49:58 +00:00
type SmartProps = {
id: string;
style?: CSSProperties;
2019-01-14 21:49:58 +00:00
};
function mapStateToProps(state: StateType, ourProps: SmartProps) {
const { id, style } = ourProps;
2019-01-14 21:49:58 +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');
}
return {
...props,
i18n: getIntl(state),
style,
};
2019-01-14 21:49:58 +00:00
}
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartMessageSearchResult = smart(MessageSearchResult);