Checklist: Use title for chat preview (#6242)

This commit is contained in:
zubiden 2025-09-19 14:34:53 +02:00 committed by Alexander Zinchuk
parent f97dd09216
commit 9b8b809d12
2 changed files with 15 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import { withGlobal } from '../../global';
import type { import type {
ApiFormattedText, ApiMessage, ApiPoll, ApiTypeStory, ApiFormattedText, ApiMessage, ApiPoll, ApiTypeStory,
ApiWebPage,
} from '../../api/types'; } from '../../api/types';
import type { ObserveFn } from '../../hooks/useIntersectionObserver'; import type { ObserveFn } from '../../hooks/useIntersectionObserver';
@ -18,7 +19,7 @@ import {
getMessageSummaryText, getMessageSummaryText,
TRUNCATED_SUMMARY_LENGTH, TRUNCATED_SUMMARY_LENGTH,
} from '../../global/helpers/messageSummary'; } from '../../global/helpers/messageSummary';
import { selectPeerStory, selectPollFromMessage } from '../../global/selectors'; import { selectPeerStory, selectPollFromMessage, selectWebPageFromMessage } from '../../global/selectors';
import trimText from '../../util/trimText'; import trimText from '../../util/trimText';
import renderText from './helpers/renderText'; import renderText from './helpers/renderText';
@ -43,19 +44,21 @@ type OwnProps = {
type StateProps = { type StateProps = {
poll?: ApiPoll; poll?: ApiPoll;
story?: ApiTypeStory; story?: ApiTypeStory;
webPage?: ApiWebPage;
}; };
function MessageSummary({ function MessageSummary({
message, message,
translatedText, translatedText,
noEmoji = false, noEmoji,
highlight, highlight,
truncateLength = TRUNCATED_SUMMARY_LENGTH, truncateLength = TRUNCATED_SUMMARY_LENGTH,
withTranslucentThumbs = false, withTranslucentThumbs,
inChatList = false, inChatList,
emojiSize, emojiSize,
poll, poll,
story, story,
webPage,
observeIntersectionForLoading, observeIntersectionForLoading,
observeIntersectionForPlaying, observeIntersectionForPlaying,
}: OwnProps & StateProps) { }: OwnProps & StateProps) {
@ -64,7 +67,7 @@ function MessageSummary({
const hasPoll = Boolean(getMessagePollId(message)); const hasPoll = Boolean(getMessagePollId(message));
const isAction = isActionMessage(message); const isAction = isActionMessage(message);
const statefulContent = groupStatefulContent({ poll, story }); const statefulContent = groupStatefulContent({ poll, story, webPage });
if (!extractedText && !hasPoll && !isAction) { if (!extractedText && !hasPoll && !isAction) {
const summaryText = translatedText?.text const summaryText = translatedText?.text
@ -118,12 +121,14 @@ function MessageSummary({
export default memo(withGlobal<OwnProps>( export default memo(withGlobal<OwnProps>(
(global, { message }): StateProps => { (global, { message }): StateProps => {
const poll = selectPollFromMessage(global, message); const poll = selectPollFromMessage(global, message);
const webPage = selectWebPageFromMessage(global, message);
const storyData = message.content.storyData; const storyData = message.content.storyData;
const story = storyData && selectPeerStory(global, storyData.peerId, storyData.id); const story = storyData && selectPeerStory(global, storyData.peerId, storyData.id);
return { return {
poll, poll,
story, story,
webPage,
}; };
}, },
)(MessageSummary)); )(MessageSummary));

View File

@ -249,7 +249,11 @@ function getSummaryDescription(
} }
if (todo) { if (todo) {
summary = lang('AttachTodo'); summary = renderTextWithEntities({
text: todo.todo.title.text,
entities: todo.todo.title.entities,
asPreview: true,
});
} }
return summary || lang('MessageUnsupported'); return summary || lang('MessageUnsupported');