mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 00:36:53 +00:00
Display channel posts in discussion groups.
This commit is contained in:
parent
50778790fe
commit
9c1ce702bb
@ -233,9 +233,20 @@ bool HistoryMessageReply::isNameUpdated() const {
|
||||
|
||||
void HistoryMessageReply::updateName() const {
|
||||
if (replyToMsg) {
|
||||
QString name = (replyToVia && replyToMsg->author()->isUser())
|
||||
? replyToMsg->author()->asUser()->firstName
|
||||
: App::peerName(replyToMsg->author());
|
||||
const auto from = [&] {
|
||||
if (const auto message = replyToMsg->toHistoryMessage()) {
|
||||
if (const auto from = message->displayFrom()) {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
return replyToMsg->author().get();
|
||||
}();
|
||||
const auto name = [&] {
|
||||
if (replyToVia && from->isUser()) {
|
||||
return from->asUser()->firstName;
|
||||
}
|
||||
return App::peerName(from);
|
||||
}();
|
||||
replyToName.setText(st::fwdTextStyle, name, Ui::NameTextOptions());
|
||||
replyToVersion = replyToMsg->author()->nameVersion;
|
||||
bool hasPreview = replyToMsg->media() ? replyToMsg->media()->hasReplyPreview() : false;
|
||||
|
@ -553,8 +553,16 @@ int HistoryMessage::viewsCount() const {
|
||||
return HistoryItem::viewsCount();
|
||||
}
|
||||
|
||||
bool HistoryMessage::displayForwardedAsOriginal() const {
|
||||
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
const auto peer = history()->peer;
|
||||
return peer->isSelf() || (peer->isMegagroup() && (peer == from()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PeerData *HistoryMessage::displayFrom() const {
|
||||
return history()->peer->isSelf()
|
||||
return displayForwardedAsOriginal()
|
||||
? senderOriginal()
|
||||
: author().get();
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
MsgId dependencyMsgId() const override {
|
||||
return replyToId();
|
||||
}
|
||||
bool displayForwardedAsOriginal() const;
|
||||
|
||||
HistoryMessage *toHistoryMessage() override { // dynamic_cast optimize
|
||||
return this;
|
||||
@ -170,7 +171,6 @@ private:
|
||||
const MTPDmessageFwdHeader &data);
|
||||
|
||||
void updateAdminBadgeState();
|
||||
ClickHandlerPtr fastReplyLink() const;
|
||||
|
||||
QString _timeText;
|
||||
int _timeWidth = 0;
|
||||
|
@ -358,15 +358,20 @@ void Element::refreshDataId() {
|
||||
}
|
||||
|
||||
bool Element::computeIsAttachToPrevious(not_null<Element*> previous) {
|
||||
const auto mayBeAttached = [](not_null<HistoryItem*> item) {
|
||||
return !item->serviceMsg()
|
||||
&& !item->isEmpty()
|
||||
&& !item->isPost()
|
||||
&& (item->from() != item->history()->peer
|
||||
|| !item->from()->isChannel());
|
||||
};
|
||||
const auto item = data();
|
||||
if (!Has<DateBadge>() && !Has<UnreadBar>()) {
|
||||
const auto prev = previous->data();
|
||||
const auto possible = !item->serviceMsg() && !prev->serviceMsg()
|
||||
&& !item->isEmpty() && !prev->isEmpty()
|
||||
&& (std::abs(prev->date() - item->date())
|
||||
const auto possible = (std::abs(prev->date() - item->date())
|
||||
< kAttachMessageToPreviousSecondsDelta)
|
||||
&& (/*_context == Context::Feed // #feed
|
||||
|| */(!item->isPost() && !prev->isPost()));
|
||||
&& mayBeAttached(item)
|
||||
&& mayBeAttached(prev);
|
||||
if (possible) {
|
||||
if (item->history()->peer->isSelf()) {
|
||||
return IsAttachedToPreviousInSavedMessages(prev, item);
|
||||
|
@ -1335,10 +1335,9 @@ bool Message::displayFromName() const {
|
||||
|
||||
bool Message::displayForwardedFrom() const {
|
||||
const auto item = message();
|
||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
if (item->history()->peer->isSelf()) {
|
||||
return false;
|
||||
}
|
||||
if (item->displayForwardedAsOriginal()) {
|
||||
return false;
|
||||
} else if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
const auto media = this->media();
|
||||
return item->Has<HistoryMessageVia>()
|
||||
|| !media
|
||||
@ -1419,11 +1418,8 @@ bool Message::displayFastShare() const {
|
||||
|
||||
bool Message::displayGoToOriginal() const {
|
||||
const auto item = message();
|
||||
const auto peer = item->history()->peer;
|
||||
if (peer->isSelf()) {
|
||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->savedFromPeer && forwarded->savedFromMsgId;
|
||||
}
|
||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->savedFromPeer && forwarded->savedFromMsgId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user