mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Fix forwarded message with custom emoji preview.
This commit is contained in:
parent
66d2c06eb4
commit
57b0ec0d7e
5 changed files with 39 additions and 7 deletions
Telegram/SourceFiles/history
|
@ -667,6 +667,7 @@ void HistoryItem::applySentMessage(const MTPDmessage &data) {
|
|||
setPostAuthor(data.vpost_author().value_or_empty());
|
||||
contributeToSlowmode(data.vdate().v);
|
||||
indexAsNewItem();
|
||||
invalidateChatListEntry();
|
||||
history()->owner().notifyItemDataChange(this);
|
||||
history()->owner().requestItemTextRefresh(this);
|
||||
history()->owner().updateDependentMessages(this);
|
||||
|
@ -686,6 +687,7 @@ void HistoryItem::applySentMessage(
|
|||
if (!wasAlready) {
|
||||
indexAsNewItem();
|
||||
}
|
||||
invalidateChatListEntry();
|
||||
}
|
||||
|
||||
void HistoryItem::indexAsNewItem() {
|
||||
|
@ -1035,6 +1037,14 @@ Data::MessagePosition HistoryItem::position() const {
|
|||
return { .fullId = fullId(), .date = date() };
|
||||
}
|
||||
|
||||
bool HistoryItem::computeDropForwardedInfo() const {
|
||||
const auto media = this->media();
|
||||
return (media && media->dropForwardedInfo())
|
||||
|| (history()->peer->isSelf()
|
||||
&& !Has<HistoryMessageForwarded>()
|
||||
&& (!media || !media->forceForwardedInfo()));
|
||||
}
|
||||
|
||||
MsgId HistoryItem::replyToId() const {
|
||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||
return reply->replyToId();
|
||||
|
|
|
@ -395,6 +395,7 @@ public:
|
|||
[[nodiscard]] Data::Media *media() const {
|
||||
return _media.get();
|
||||
}
|
||||
[[nodiscard]] bool computeDropForwardedInfo() const;
|
||||
virtual void setText(const TextWithEntities &textWithEntities) {
|
||||
}
|
||||
[[nodiscard]] virtual bool textHasLinks() const {
|
||||
|
|
|
@ -239,6 +239,16 @@ QString GetErrorTextForSending(
|
|||
return GetErrorTextForSending(peer, items, {}, ignoreSlowmodeCountdown);
|
||||
}
|
||||
|
||||
TextWithEntities DropCustomEmoji(TextWithEntities text) {
|
||||
text.entities.erase(
|
||||
ranges::remove(
|
||||
text.entities,
|
||||
EntityType::CustomEmoji,
|
||||
&EntityInText::type),
|
||||
text.entities.end());
|
||||
return text;
|
||||
}
|
||||
|
||||
struct HistoryMessage::CreateConfig {
|
||||
PeerId replyToPeer = 0;
|
||||
MsgId replyTo = 0;
|
||||
|
@ -401,11 +411,7 @@ HistoryMessage::HistoryMessage(
|
|||
auto config = CreateConfig();
|
||||
|
||||
const auto originalMedia = original->media();
|
||||
const auto dropForwardInfo = (originalMedia
|
||||
&& originalMedia->dropForwardedInfo())
|
||||
|| (original->history()->peer->isSelf()
|
||||
&& !original->Has<HistoryMessageForwarded>()
|
||||
&& (!originalMedia || !originalMedia->forceForwardedInfo()));
|
||||
const auto dropForwardInfo = original->computeDropForwardedInfo();
|
||||
if (!dropForwardInfo) {
|
||||
config.originalDate = original->dateOriginal();
|
||||
if (const auto info = original->hiddenSenderInfo()) {
|
||||
|
@ -473,7 +479,13 @@ HistoryMessage::HistoryMessage(
|
|||
if (mediaOriginal && !ignoreMedia()) {
|
||||
_media = mediaOriginal->clone(this);
|
||||
}
|
||||
setText(original->originalText());
|
||||
|
||||
const auto dropCustomEmoji = dropForwardInfo
|
||||
&& !history->session().premium()
|
||||
&& !history->peer->isSelf();
|
||||
setText(dropCustomEmoji
|
||||
? DropCustomEmoji(original->originalText())
|
||||
: original->originalText());
|
||||
}
|
||||
|
||||
HistoryMessage::HistoryMessage(
|
||||
|
|
|
@ -49,6 +49,7 @@ void RequestDependentMessageData(
|
|||
const HistoryItemsList &items,
|
||||
const TextWithTags &comment,
|
||||
bool ignoreSlowmodeCountdown = false);
|
||||
[[nodiscard]] TextWithEntities DropCustomEmoji(TextWithEntities text);
|
||||
|
||||
class HistoryMessage final : public HistoryItem {
|
||||
public:
|
||||
|
|
|
@ -7545,11 +7545,19 @@ void HistoryWidget::updateForwardingTexts() {
|
|||
}
|
||||
|
||||
if (count < 2) {
|
||||
text = _toForward.items.front()->toPreview({
|
||||
const auto item = _toForward.items.front();
|
||||
text = item->toPreview({
|
||||
.hideSender = true,
|
||||
.hideCaption = !keepCaptions,
|
||||
.generateImages = false,
|
||||
}).text;
|
||||
|
||||
const auto dropCustomEmoji = !session().premium()
|
||||
&& !_peer->isSelf()
|
||||
&& (item->computeDropForwardedInfo() || !keepNames);
|
||||
if (dropCustomEmoji) {
|
||||
text = DropCustomEmoji(std::move(text));
|
||||
}
|
||||
} else {
|
||||
text = Ui::Text::PlainLink(
|
||||
tr::lng_forward_messages(tr::now, lt_count, count));
|
||||
|
|
Loading…
Add table
Reference in a new issue