mirror of https://github.com/procxx/kepka.git
Correctly display discussion posts.
This commit is contained in:
parent
371f1a51c3
commit
6b9675a5b1
|
@ -553,18 +553,30 @@ int HistoryMessage::viewsCount() const {
|
||||||
return HistoryItem::viewsCount();
|
return HistoryItem::viewsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::displayForwardedAsOriginal() const {
|
ChannelData *HistoryMessage::discussionPostOriginalSender() const {
|
||||||
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
if (!history()->peer->isMegagroup()) {
|
||||||
const auto peer = history()->peer;
|
return nullptr;
|
||||||
return peer->isSelf() || (peer->isMegagroup() && (peer == from()));
|
|
||||||
}
|
}
|
||||||
return false;
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
|
const auto from = forwarded->savedFromPeer;
|
||||||
|
if (const auto result = from ? from->asChannel() : nullptr) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryMessage::isDiscussionPost() const {
|
||||||
|
return (discussionPostOriginalSender() != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerData *HistoryMessage::displayFrom() const {
|
PeerData *HistoryMessage::displayFrom() const {
|
||||||
return displayForwardedAsOriginal()
|
if (const auto sender = discussionPostOriginalSender()) {
|
||||||
? senderOriginal()
|
return sender;
|
||||||
: author().get();
|
} else if (history()->peer->isSelf()) {
|
||||||
|
return senderOriginal();
|
||||||
|
}
|
||||||
|
return author().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::updateDependencyItem() {
|
bool HistoryMessage::updateDependencyItem() {
|
||||||
|
@ -611,8 +623,7 @@ bool HistoryMessage::allowsForward() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::hasMessageBadge() const {
|
bool HistoryMessage::hasMessageBadge() const {
|
||||||
return hasAdminBadge()
|
return hasAdminBadge() || isDiscussionPost();
|
||||||
|| (displayForwardedAsOriginal() && !history()->peer->isSelf());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::isTooOldForEdit(TimeId now) const {
|
bool HistoryMessage::isTooOldForEdit(TimeId now) const {
|
||||||
|
|
|
@ -136,7 +136,8 @@ public:
|
||||||
[[nodiscard]] MsgId dependencyMsgId() const override {
|
[[nodiscard]] MsgId dependencyMsgId() const override {
|
||||||
return replyToId();
|
return replyToId();
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool displayForwardedAsOriginal() const;
|
[[nodiscard]] ChannelData *discussionPostOriginalSender() const;
|
||||||
|
[[nodiscard]] bool isDiscussionPost() const;
|
||||||
|
|
||||||
// dynamic_cast optimization.
|
// dynamic_cast optimization.
|
||||||
[[nodiscard]] HistoryMessage *toHistoryMessage() override {
|
[[nodiscard]] HistoryMessage *toHistoryMessage() override {
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -1337,9 +1338,15 @@ bool Message::displayFromName() const {
|
||||||
|
|
||||||
bool Message::displayForwardedFrom() const {
|
bool Message::displayForwardedFrom() const {
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
if (item->displayForwardedAsOriginal()) {
|
if (item->history()->peer->isSelf()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
}
|
||||||
|
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||||
|
if (const auto sender = item->discussionPostOriginalSender()) {
|
||||||
|
if (sender == forwarded->originalSender) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
const auto media = this->media();
|
const auto media = this->media();
|
||||||
return item->Has<HistoryMessageVia>()
|
return item->Has<HistoryMessageVia>()
|
||||||
|| !media
|
|| !media
|
||||||
|
|
Loading…
Reference in New Issue