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 lang = useLang();
const senderTitle = sender && getSenderTitle(lang, sender); const senderTitle = message?.forwardInfo?.hiddenUserName || (sender && getSenderTitle(lang, sender));
return ( return (
<div <div

View File

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