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