diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 6fb9d33ee3..a24af6159b 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -650,13 +650,15 @@ void HistoryItem::finishCreate() { void HistoryItem::finishEdition(int oldKeyboardTop) { setPendingInitDimensions(); - if (App::main()) { - App::main()->dlgUpdated(history()->peer, id); - } - - // invalidate cache for drawInDialog - if (history()->textCachedFor == this) { - history()->textCachedFor = nullptr; + invalidateChatsListEntry(); + //if (groupId()) { + // history()->fixGroupAfterEdition(this); + //} + if (isHiddenByGroup()) { + // Perhaps caption was changed, we should refresh the group. + const auto group = Get(); + group->leader->setPendingInitDimensions(); + group->leader->invalidateChatsListEntry(); } if (oldKeyboardTop >= 0) { @@ -668,6 +670,17 @@ void HistoryItem::finishEdition(int oldKeyboardTop) { App::historyUpdateDependent(this); } +void HistoryItem::invalidateChatsListEntry() { + if (App::main()) { + App::main()->dlgUpdated(history()->peer, id); + } + + // invalidate cache for drawInDialog + if (history()->textCachedFor == this) { + history()->textCachedFor = nullptr; + } +} + void HistoryItem::finishEditionToEmpty() { recountDisplayDate(); finishEdition(-1); @@ -1193,6 +1206,7 @@ void HistoryItem::makeGroupLeader( group->others = std::move(others); if (!_media || !_media->applyGroup(group->others)) { resetGroupMedia(group->others); + invalidateChatsListEntry(); } Ensures(!isHiddenByGroup()); diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 815215aacc..718c9660f6 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -1094,6 +1094,7 @@ protected: } return nullptr; } + void invalidateChatsListEntry(); [[nodiscard]] TextSelection skipTextSelection( TextSelection selection) const { diff --git a/Telegram/SourceFiles/history/history_media_grouped.cpp b/Telegram/SourceFiles/history/history_media_grouped.cpp index 3c4f5bf644..c783664f9e 100644 --- a/Telegram/SourceFiles/history/history_media_grouped.cpp +++ b/Telegram/SourceFiles/history/history_media_grouped.cpp @@ -279,7 +279,7 @@ TextSelection HistoryGroupedMedia::adjustSelection( } QString HistoryGroupedMedia::notificationText() const { - return WithCaptionNotificationText(lang(lng_in_dlg_album), _caption); + return WithCaptionNotificationText(lang(lng_in_dlg_photo), _caption); } QString HistoryGroupedMedia::inDialogsText() const { @@ -393,14 +393,23 @@ Storage::SharedMediaTypesMask HistoryGroupedMedia::sharedMediaTypes() const { } void HistoryGroupedMedia::updateNeedBubbleState() { - auto captionText = [&] { - for (const auto &element : _elements) { - auto result = element.content->getCaption(); - if (!result.text.isEmpty()) { - return result; + const auto getItemCaption = [](const Element &element) { + if (const auto media = element.item->getMedia()) { + return media->getCaption(); + } + return element.content->getCaption(); + }; + const auto captionText = [&] { + auto result = getItemCaption(_elements.front()); + if (result.text.isEmpty()) { + return result; + } + for (auto i = 1, count = int(_elements.size()); i != count; ++i) { + if (!getItemCaption(_elements[i]).text.isEmpty()) { + return TextWithEntities(); } } - return TextWithEntities(); + return result; }(); _caption.setText( st::messageTextStyle,