Message: Show correct message sender when forwarding (another attempt) (#1822)

This commit is contained in:
Alexander Zinchuk 2022-04-19 15:11:35 +02:00
parent 2866922d3c
commit b06bbe1197
2 changed files with 13 additions and 6 deletions

View File

@ -54,7 +54,7 @@ const EmbeddedMessage: FC<OwnProps> = ({
const lang = useLang();
const senderTitle = sender && getSenderTitle(lang, sender);
const senderTitle = message?.forwardInfo?.hiddenUserName || (sender && getSenderTitle(lang, sender));
return (
<div

View File

@ -16,6 +16,7 @@ import {
selectEditingId,
selectEditingScheduledId,
selectEditingMessage,
selectIsChatWithSelf,
} from '../../../global/selectors';
import captureEscKeyListener from '../../../util/captureEscKeyListener';
import buildClassName from '../../../util/buildClassName';
@ -127,7 +128,6 @@ export default memo(withGlobal<OwnProps>(
}
const {
currentUserId,
forwardMessages: { fromChatId, toChatId, messageIds: forwardMessageIds },
} = global;
@ -150,18 +150,25 @@ export default memo(withGlobal<OwnProps>(
let sender: ApiChat | ApiUser | undefined;
if (replyingToId && message) {
const { forwardInfo } = message;
const isChatWithSelf = chatId === currentUserId;
const isChatWithSelf = selectIsChatWithSelf(global, chatId);
if (forwardInfo && (forwardInfo.isChannelPost || isChatWithSelf)) {
sender = selectForwardedSender(global, message);
}
if (!sender) {
if (!sender && !forwardInfo?.hiddenUserName) {
sender = selectSender(global, message);
}
} else if (isForwarding) {
if (message) {
sender = selectForwardedSender(global, message);
if (!sender) {
sender = selectSender(global, message);
}
}
if (!sender) {
sender = isUserId(fromChatId!) ? selectUser(global, fromChatId!) : selectChat(global, fromChatId!);
}
}
return {
replyingToId,