Take album caption from any album item.

This commit is contained in:
John Preston 2019-03-22 14:22:32 +04:00
parent ca9db9fd3f
commit db121c0839
1 changed files with 12 additions and 10 deletions

View File

@ -390,19 +390,21 @@ HistoryMessageEdited *HistoryGroupedMedia::displayedEditBadge() const {
}
void HistoryGroupedMedia::updateNeedBubbleState() {
const auto hasCaption = [&] {
if (_parts.front().item->emptyText()) {
return false;
}
for (auto i = 1, count = int(_parts.size()); i != count; ++i) {
if (!_parts[i].item->emptyText()) {
return false;
const auto captionItem = [&]() -> HistoryItem* {
auto result = (HistoryItem*)nullptr;
for (const auto &part : _parts) {
if (!part.item->emptyText()) {
if (result) {
return nullptr;
} else {
result = part.item;
}
}
}
return true;
return result;
}();
if (hasCaption) {
_caption = createCaption(_parts.front().item);
if (captionItem) {
_caption = createCaption(captionItem);
}
_needBubble = computeNeedBubble();
}