Album: Fix displaying caption in some cases (#4468)
This commit is contained in:
parent
1b0d050c66
commit
61de4544d5
@ -38,11 +38,20 @@ export function groupMessages(
|
|||||||
albumId: message.groupedId!,
|
albumId: message.groupedId!,
|
||||||
messages: [message],
|
messages: [message],
|
||||||
mainMessage: message,
|
mainMessage: message,
|
||||||
|
hasMultipleCaptions: false,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
currentAlbum.messages.push(message);
|
currentAlbum.messages.push(message);
|
||||||
if (message.hasComments || (message.content.text && !currentAlbum.mainMessage.hasComments)) {
|
if (message.hasComments) {
|
||||||
currentAlbum.mainMessage = message;
|
currentAlbum.commentsMessage = message;
|
||||||
|
}
|
||||||
|
if (message.content.text && !currentAlbum.hasMultipleCaptions) {
|
||||||
|
if (currentAlbum.captionMessage) {
|
||||||
|
currentAlbum.hasMultipleCaptions = true;
|
||||||
|
currentAlbum.captionMessage = undefined;
|
||||||
|
} else {
|
||||||
|
currentAlbum.captionMessage = message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -541,7 +541,6 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
const avatarPeer = shouldPreferOriginSender ? originSender : messageSender;
|
const avatarPeer = shouldPreferOriginSender ? originSender : messageSender;
|
||||||
const messageColorPeer = originSender || sender;
|
const messageColorPeer = originSender || sender;
|
||||||
const senderPeer = (forwardInfo || message.content.storyData) ? originSender : messageSender;
|
const senderPeer = (forwardInfo || message.content.storyData) ? originSender : messageSender;
|
||||||
const hasText = hasMessageText(message);
|
|
||||||
const hasTtl = hasMessageTtl(message);
|
const hasTtl = hasMessageTtl(message);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -623,6 +622,9 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [focusLastMessage, isLastInList, transcribedText, withVoiceTranscription]);
|
}, [focusLastMessage, isLastInList, transcribedText, withVoiceTranscription]);
|
||||||
|
|
||||||
|
const textMessage = album?.hasMultipleCaptions ? undefined : (album?.captionMessage || message);
|
||||||
|
const hasText = textMessage && hasMessageText(textMessage);
|
||||||
|
|
||||||
const containerClassName = buildClassName(
|
const containerClassName = buildClassName(
|
||||||
'Message message-list-item',
|
'Message message-list-item',
|
||||||
isFirstInGroup && 'first-in-group',
|
isFirstInGroup && 'first-in-group',
|
||||||
@ -654,12 +656,13 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
text, photo, video, audio,
|
photo, video, audio,
|
||||||
voice, document, sticker, contact,
|
voice, document, sticker, contact,
|
||||||
poll, webPage, invoice, location,
|
poll, webPage, invoice, location,
|
||||||
action, game, storyData, giveaway,
|
action, game, storyData, giveaway,
|
||||||
giveawayResults,
|
giveawayResults,
|
||||||
} = getMessageContent(message);
|
} = getMessageContent(message);
|
||||||
|
const text = textMessage && getMessageContent(textMessage).text;
|
||||||
|
|
||||||
const { replyToMsgId, replyToPeerId, isQuote } = messageReplyInfo || {};
|
const { replyToMsgId, replyToPeerId, isQuote } = messageReplyInfo || {};
|
||||||
const { peerId: storyReplyPeerId, storyId: storyReplyId } = storyReplyInfo || {};
|
const { peerId: storyReplyPeerId, storyId: storyReplyId } = storyReplyInfo || {};
|
||||||
@ -692,7 +695,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
const withQuickReactionButton = !isTouchScreen && !phoneCall && !isInSelectMode && defaultReaction
|
const withQuickReactionButton = !isTouchScreen && !phoneCall && !isInSelectMode && defaultReaction
|
||||||
&& !isInDocumentGroupNotLast && !isStoryMention && !hasTtl;
|
&& !isInDocumentGroupNotLast && !isStoryMention && !hasTtl;
|
||||||
|
|
||||||
const contentClassName = buildContentClassName(message, {
|
const contentClassName = buildContentClassName(message, album, {
|
||||||
hasSubheader,
|
hasSubheader,
|
||||||
isCustomShape,
|
isCustomShape,
|
||||||
isLastInGroup,
|
isLastInGroup,
|
||||||
@ -889,9 +892,10 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMessageText(isForAnimation?: boolean) {
|
function renderMessageText(isForAnimation?: boolean) {
|
||||||
|
if (!textMessage) return undefined;
|
||||||
return (
|
return (
|
||||||
<MessageText
|
<MessageText
|
||||||
messageOrStory={message}
|
messageOrStory={textMessage}
|
||||||
translatedText={requestedTranslationLanguage ? currentTranslatedText : undefined}
|
translatedText={requestedTranslationLanguage ? currentTranslatedText : undefined}
|
||||||
isForAnimation={isForAnimation}
|
isForAnimation={isForAnimation}
|
||||||
focusedQuote={focusedQuote}
|
focusedQuote={focusedQuote}
|
||||||
@ -1563,7 +1567,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { canReply } = (messageListType === 'thread' && selectAllowedMessageActions(global, message, threadId)) || {};
|
const { canReply } = (messageListType === 'thread' && selectAllowedMessageActions(global, message, threadId)) || {};
|
||||||
const isDownloading = selectIsDownloading(global, message);
|
const isDownloading = selectIsDownloading(global, message);
|
||||||
|
|
||||||
const repliesThreadInfo = selectThreadInfo(global, chatId, album?.mainMessage.id || id);
|
const repliesThreadInfo = selectThreadInfo(global, chatId, album?.commentsMessage?.id || id);
|
||||||
|
|
||||||
const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum;
|
const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum;
|
||||||
const documentGroupFirstMessageId = isInDocumentGroup
|
const documentGroupFirstMessageId = isInDocumentGroup
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import type { ApiMessage } from '../../../../api/types';
|
import type { ApiMessage } from '../../../../api/types';
|
||||||
|
import type { IAlbum } from '../../../../types';
|
||||||
|
|
||||||
import { EMOJI_SIZES, MESSAGE_CONTENT_CLASS_NAME } from '../../../../config';
|
import { EMOJI_SIZES, MESSAGE_CONTENT_CLASS_NAME } from '../../../../config';
|
||||||
import { getMessageContent } from '../../../../global/helpers';
|
import { getMessageContent } from '../../../../global/helpers';
|
||||||
|
|
||||||
export function buildContentClassName(
|
export function buildContentClassName(
|
||||||
message: ApiMessage,
|
message: ApiMessage,
|
||||||
|
album?: IAlbum,
|
||||||
{
|
{
|
||||||
hasSubheader,
|
hasSubheader,
|
||||||
isCustomShape,
|
isCustomShape,
|
||||||
@ -34,9 +36,10 @@ export function buildContentClassName(
|
|||||||
} = {},
|
} = {},
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
text, photo, video, audio, voice, document, poll, webPage, contact, location, invoice, storyData,
|
photo, video, audio, voice, document, poll, webPage, contact, location, invoice, storyData,
|
||||||
giveaway, giveawayResults,
|
giveaway, giveawayResults,
|
||||||
} = getMessageContent(message);
|
} = getMessageContent(message);
|
||||||
|
const text = album?.hasMultipleCaptions ? undefined : getMessageContent(album?.captionMessage || message).text;
|
||||||
|
|
||||||
const classNames = [MESSAGE_CONTENT_CLASS_NAME];
|
const classNames = [MESSAGE_CONTENT_CLASS_NAME];
|
||||||
const isMedia = storyData || photo || video || location || invoice?.extendedMedia;
|
const isMedia = storyData || photo || video || location || invoice?.extendedMedia;
|
||||||
|
|||||||
@ -27,6 +27,9 @@ export interface IAlbum {
|
|||||||
albumId: string;
|
albumId: string;
|
||||||
messages: ApiMessage[];
|
messages: ApiMessage[];
|
||||||
mainMessage: ApiMessage;
|
mainMessage: ApiMessage;
|
||||||
|
captionMessage?: ApiMessage;
|
||||||
|
hasMultipleCaptions: boolean;
|
||||||
|
commentsMessage?: ApiMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ThreadId = string | number;
|
export type ThreadId = string | number;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user