Fix reply-returns in just sent messages.

This commit is contained in:
John Preston 2018-06-04 19:58:35 +03:00
parent a42fb1f7b7
commit 1d1bd5e1e7
4 changed files with 16 additions and 2 deletions

View File

@ -473,7 +473,7 @@ Data::MessagePosition HistoryItem::position() const {
}
MsgId HistoryItem::replyToId() const {
if (auto reply = Get<HistoryMessageReply>()) {
if (const auto reply = Get<HistoryMessageReply>()) {
return reply->replyToId();
}
return 0;

View File

@ -154,7 +154,7 @@ bool HistoryMessageReply::updateData(
updateName();
replyToLnk = goToMessageClickHandler(replyToMsg, holder->fullId());
setReplyToLinkFrom(holder);
if (!replyToMsg->Has<HistoryMessageForwarded>()) {
if (auto bot = replyToMsg->viaBot()) {
replyToVia = std::make_unique<HistoryMessageVia>();
@ -170,6 +170,13 @@ bool HistoryMessageReply::updateData(
return (replyToMsg || !replyToMsgId);
}
void HistoryMessageReply::setReplyToLinkFrom(
not_null<HistoryMessage*> holder) {
replyToLnk = replyToMsg
? goToMessageClickHandler(replyToMsg, holder->fullId())
: nullptr;
}
void HistoryMessageReply::clearData(not_null<HistoryMessage*> holder) {
replyToVia = nullptr;
if (replyToMsg) {

View File

@ -117,6 +117,8 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, Histor
ClickHandlerPtr replyToLink() const {
return replyToLnk;
}
void setReplyToLinkFrom(
not_null<HistoryMessage*> holder);
MsgId replyToMsgId = 0;
HistoryItem *replyToMsg = nullptr;

View File

@ -1082,6 +1082,11 @@ void HistoryMessage::setRealId(MsgId newId) {
HistoryItem::setRealId(newId);
Auth().data().groups().refreshMessage(this);
Auth().data().requestItemResize(this);
if (const auto reply = Get<HistoryMessageReply>()) {
if (reply->replyToLink()) {
reply->setReplyToLinkFrom(this);
}
}
}
void HistoryMessage::dependencyItemRemoved(HistoryItem *dependency) {