mirror of https://github.com/procxx/kepka.git
Correctly display discussion posts sender.
This commit is contained in:
parent
01054858a4
commit
a64c8c52b4
|
@ -740,14 +740,8 @@ void RowPainter::paint(
|
||||||
auto history = item->history();
|
auto history = item->history();
|
||||||
auto cloudDraft = nullptr;
|
auto cloudDraft = nullptr;
|
||||||
const auto from = [&] {
|
const auto from = [&] {
|
||||||
if (const auto searchChat = row->searchInChat()) {
|
if (row->searchInChat()) {
|
||||||
if (const auto peer = searchChat.peer()) {
|
return item->displayFrom();
|
||||||
if (peer->isSelf()) {
|
|
||||||
return item->senderOriginal();
|
|
||||||
} else if (!peer->isChannel() || peer->isMegagroup()) {
|
|
||||||
return item->from().get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return history->peer->migrateTo()
|
return history->peer->migrateTo()
|
||||||
? history->peer->migrateTo()
|
? history->peer->migrateTo()
|
||||||
|
|
|
@ -218,6 +218,32 @@ ReplyKeyboard *HistoryItem::inlineReplyKeyboard() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChannelData *HistoryItem::discussionPostOriginalSender() const {
|
||||||
|
if (!history()->peer->isMegagroup()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
|
const auto from = forwarded->savedFromPeer;
|
||||||
|
if (const auto result = from ? from->asChannel() : nullptr) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryItem::isDiscussionPost() const {
|
||||||
|
return (discussionPostOriginalSender() != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
PeerData *HistoryItem::displayFrom() const {
|
||||||
|
if (const auto sender = discussionPostOriginalSender()) {
|
||||||
|
return sender;
|
||||||
|
} else if (history()->peer->isSelf()) {
|
||||||
|
return senderOriginal();
|
||||||
|
}
|
||||||
|
return author().get();
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryItem::invalidateChatListEntry() {
|
void HistoryItem::invalidateChatListEntry() {
|
||||||
if (const auto main = App::main()) {
|
if (const auto main = App::main()) {
|
||||||
// #TODO feeds search results
|
// #TODO feeds search results
|
||||||
|
@ -706,7 +732,7 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const {
|
||||||
if (isPost() || isEmpty() || (way == DrawInDialog::WithoutSender)) {
|
if (isPost() || isEmpty() || (way == DrawInDialog::WithoutSender)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else if (!_history->peer->isUser() || out()) {
|
} else if (!_history->peer->isUser() || out()) {
|
||||||
return author();
|
return displayFrom();
|
||||||
} else if (_history->peer->isSelf() && !Has<HistoryMessageForwarded>()) {
|
} else if (_history->peer->isSelf() && !Has<HistoryMessageForwarded>()) {
|
||||||
return senderOriginal();
|
return senderOriginal();
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,6 +305,10 @@ public:
|
||||||
HistoryMessageReplyMarkup *inlineReplyMarkup();
|
HistoryMessageReplyMarkup *inlineReplyMarkup();
|
||||||
ReplyKeyboard *inlineReplyKeyboard();
|
ReplyKeyboard *inlineReplyKeyboard();
|
||||||
|
|
||||||
|
[[nodiscard]] ChannelData *discussionPostOriginalSender() const;
|
||||||
|
[[nodiscard]] bool isDiscussionPost() const;
|
||||||
|
[[nodiscard]] PeerData *displayFrom() const;
|
||||||
|
|
||||||
virtual std::unique_ptr<HistoryView::Element> createView(
|
virtual std::unique_ptr<HistoryView::Element> createView(
|
||||||
not_null<HistoryView::ElementDelegate*> delegate) = 0;
|
not_null<HistoryView::ElementDelegate*> delegate) = 0;
|
||||||
|
|
||||||
|
|
|
@ -234,10 +234,8 @@ bool HistoryMessageReply::isNameUpdated() const {
|
||||||
void HistoryMessageReply::updateName() const {
|
void HistoryMessageReply::updateName() const {
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
const auto from = [&] {
|
const auto from = [&] {
|
||||||
if (const auto message = replyToMsg->toHistoryMessage()) {
|
if (const auto from = replyToMsg->displayFrom()) {
|
||||||
if (const auto from = message->displayFrom()) {
|
return from;
|
||||||
return from;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return replyToMsg->author().get();
|
return replyToMsg->author().get();
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -577,32 +577,6 @@ int HistoryMessage::viewsCount() const {
|
||||||
return HistoryItem::viewsCount();
|
return HistoryItem::viewsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelData *HistoryMessage::discussionPostOriginalSender() const {
|
|
||||||
if (!history()->peer->isMegagroup()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
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 {
|
|
||||||
if (const auto sender = discussionPostOriginalSender()) {
|
|
||||||
return sender;
|
|
||||||
} else if (history()->peer->isSelf()) {
|
|
||||||
return senderOriginal();
|
|
||||||
}
|
|
||||||
return author().get();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HistoryMessage::updateDependencyItem() {
|
bool HistoryMessage::updateDependencyItem() {
|
||||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||||
return reply->updateData(this, true);
|
return reply->updateData(this, true);
|
||||||
|
|
|
@ -131,13 +131,10 @@ public:
|
||||||
[[nodiscard]] bool textHasLinks() const override;
|
[[nodiscard]] bool textHasLinks() const override;
|
||||||
|
|
||||||
[[nodiscard]] int viewsCount() const override;
|
[[nodiscard]] int viewsCount() const override;
|
||||||
[[nodiscard]] PeerData *displayFrom() const;
|
|
||||||
bool updateDependencyItem() override;
|
bool updateDependencyItem() override;
|
||||||
[[nodiscard]] MsgId dependencyMsgId() const override {
|
[[nodiscard]] MsgId dependencyMsgId() const override {
|
||||||
return replyToId();
|
return replyToId();
|
||||||
}
|
}
|
||||||
[[nodiscard]] ChannelData *discussionPostOriginalSender() const;
|
|
||||||
[[nodiscard]] bool isDiscussionPost() const;
|
|
||||||
|
|
||||||
// dynamic_cast optimization.
|
// dynamic_cast optimization.
|
||||||
[[nodiscard]] HistoryMessage *toHistoryMessage() override {
|
[[nodiscard]] HistoryMessage *toHistoryMessage() override {
|
||||||
|
|
|
@ -6437,10 +6437,8 @@ void HistoryWidget::updateReplyToName() {
|
||||||
}
|
}
|
||||||
const auto from = [&] {
|
const auto from = [&] {
|
||||||
const auto item = _replyEditMsg ? _replyEditMsg : _kbReplyTo;
|
const auto item = _replyEditMsg ? _replyEditMsg : _kbReplyTo;
|
||||||
if (const auto message = item->toHistoryMessage()) {
|
if (const auto from = item->displayFrom()) {
|
||||||
if (const auto from = message->displayFrom()) {
|
return from;
|
||||||
return from;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return item->author().get();
|
return item->author().get();
|
||||||
}();
|
}();
|
||||||
|
|
Loading…
Reference in New Issue