mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-11 08:48:14 +00:00
Use first media caption for group caption.
This commit is contained in:
parent
520a644150
commit
3e7ac7eb26
@ -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<HistoryMessageGroup>();
|
||||
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());
|
||||
|
@ -1094,6 +1094,7 @@ protected:
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void invalidateChatsListEntry();
|
||||
|
||||
[[nodiscard]] TextSelection skipTextSelection(
|
||||
TextSelection selection) const {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user