Recount grouping after leader caption edit.

This commit is contained in:
John Preston 2017-12-16 19:25:21 +04:00
parent 963e969d2a
commit 1f070da202
5 changed files with 17 additions and 1 deletions

View File

@ -2125,6 +2125,15 @@ not_null<HistoryItem*> History::findGroupLast(
return group->leader;
}
void History::recountGroupingAround(not_null<HistoryItem*> item) {
Expects(item->history() == this);
if (!item->detached() && item->groupId()) {
const auto [groupFrom, groupTill] = recountGroupingFromTill(item);
recountGrouping(groupFrom, groupTill);
}
}
auto History::recountGroupingFromTill(not_null<HistoryItem*> item)
-> std::pair<not_null<HistoryItem*>, not_null<HistoryItem*>> {
const auto recountFromItem = [&] {

View File

@ -422,6 +422,7 @@ public:
}
HistoryItemsList validateForwardDraft();
void setForwardDraft(MessageIdsList &&items);
void recountGroupingAround(not_null<HistoryItem*> item);
// some fields below are a property of a currently displayed instance of this
// conversation history not a property of the conversation history itself

View File

@ -393,6 +393,10 @@ ImagePtr HistoryGroupedMedia::replyPreview() {
return main()->replyPreview();
}
TextWithEntities HistoryGroupedMedia::getCaption() const {
return main()->getCaption();
}
Storage::SharedMediaTypesMask HistoryGroupedMedia::sharedMediaTypes() const {
return main()->sharedMediaTypes();
}

View File

@ -91,8 +91,9 @@ public:
bool hasReplyPreview() const override;
ImagePtr replyPreview() override;
TextWithEntities getCaption() const override;
Storage::SharedMediaTypesMask sharedMediaTypes() const override;
bool canBeGrouped() const override {
return true;
}

View File

@ -1608,6 +1608,7 @@ void HistoryMessage::setMedia(const MTPMessageMedia *media) {
_textWidth = -1;
_textHeight = 0;
}
_history->recountGroupingAround(this);
}
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {