2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2019 Signal Messenger, LLC
|
2024-03-13 20:44:13 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-onlyå
|
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
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';
|
2023-06-21 22:02:07 +00:00
|
|
|
import * as log from '../../logging/log';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
2019-01-14 21:49:58 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
type SmartMessageSearchResultProps = {
|
2019-01-14 21:49:58 +00:00
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartMessageSearchResult = memo(function SmartMessageSearchResult({
|
|
|
|
id,
|
|
|
|
}: SmartMessageSearchResultProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
const messageSearchResultSelector = useSelector(
|
|
|
|
getMessageSearchResultSelector
|
|
|
|
);
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
const { showConversation } = useConversationsActions();
|
|
|
|
|
|
|
|
const messageResult = messageSearchResultSelector(id);
|
|
|
|
if (messageResult == null) {
|
2023-06-21 22:02:07 +00:00
|
|
|
log.error('SmartMessageSearchResult: no message was found');
|
|
|
|
return null;
|
2021-07-07 16:37:55 +00:00
|
|
|
}
|
2024-03-13 20:44:13 +00:00
|
|
|
const { conversationId, snippet, body, bodyRanges, from, to, sentAt } =
|
|
|
|
messageResult;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MessageSearchResult
|
|
|
|
i18n={i18n}
|
|
|
|
theme={theme}
|
|
|
|
getPreferredBadge={getPreferredBadge}
|
|
|
|
id={id}
|
|
|
|
conversationId={conversationId}
|
|
|
|
snippet={snippet}
|
|
|
|
body={body}
|
|
|
|
bodyRanges={bodyRanges}
|
|
|
|
from={from}
|
|
|
|
to={to}
|
|
|
|
showConversation={showConversation}
|
|
|
|
sentAt={sentAt}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|