Fix fast reply and right action in sent messages.

Fixes #4903.
This commit is contained in:
John Preston 2018-06-28 16:20:05 +01:00
parent 165d1aacae
commit 98930792c3
5 changed files with 23 additions and 1 deletions

View File

@ -1080,6 +1080,7 @@ void HistoryMessage::setViewsCount(int32 count) {
void HistoryMessage::setRealId(MsgId newId) {
HistoryItem::setRealId(newId);
Auth().data().groups().refreshMessage(this);
Auth().data().requestItemResize(this);
if (const auto reply = Get<HistoryMessageReply>()) {

View File

@ -174,6 +174,9 @@ void Element::setY(int y) {
_y = y;
}
void Element::refreshDataIdHook() {
}
void Element::paintHighlight(
Painter &p,
int geometryHeight) const {
@ -292,6 +295,7 @@ void Element::refreshDataId() {
if (const auto media = this->media()) {
media->refreshParentId(data());
}
refreshDataIdHook();
}
bool Element::computeIsAttachToPrevious(not_null<Element*> previous) {

View File

@ -250,6 +250,8 @@ protected:
Painter &p,
int geometryHeight) const;
virtual void refreshDataIdHook();
private:
// This should be called only from previousInBlocksChanged()
// to add required bits to the Composer mask

View File

@ -1229,6 +1229,15 @@ int Message::infoWidth() const {
return result;
}
void Message::refreshDataIdHook() {
if (base::take(_rightActionLink)) {
_rightActionLink = rightActionLink();
}
if (base::take(_fastReplyLink)) {
_fastReplyLink = fastReplyLink();
}
}
int Message::timeLeft() const {
const auto item = message();
auto result = 0;
@ -1335,6 +1344,7 @@ bool Message::hasFastReply() const {
bool Message::displayFastReply() const {
return hasFastReply()
&& IsServerMsgId(data()->id)
&& data()->history()->peer->canWrite()
&& !delegate()->elementInSelectionMode();
}
@ -1346,7 +1356,9 @@ bool Message::displayRightAction() const {
bool Message::displayFastShare() const {
const auto item = message();
const auto peer = item->history()->peer;
if (peer->isChannel()) {
if (!IsServerMsgId(item->id)) {
return false;
} else if (peer->isChannel()) {
return !peer->isMegagroup();
} else if (const auto user = peer->asUser()) {
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {

View File

@ -84,6 +84,9 @@ public:
TimeId displayedEditDate() const override;
int infoWidth() const override;
protected:
void refreshDataIdHook() override;
private:
not_null<HistoryMessage*> message() const;