mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
ef10bb2bd6
commit
e2c5995a2e
1 changed files with 36 additions and 8 deletions
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "history/view/history_view_cursor_state.h"
|
#include "history/view/history_view_cursor_state.h"
|
||||||
|
#include "data/data_document.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
|
@ -652,26 +653,53 @@ HistoryMessageEdited *GroupedMedia::displayedEditBadge() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupedMedia::updateNeedBubbleState() {
|
void GroupedMedia::updateNeedBubbleState() {
|
||||||
const auto captionItem = [&]() -> HistoryItem* {
|
using PartPtrOpt = std::optional<const Part*>;
|
||||||
|
const auto captionPart = [&]() -> PartPtrOpt {
|
||||||
if (_mode == Mode::Column) {
|
if (_mode == Mode::Column) {
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
auto result = (HistoryItem*)nullptr;
|
auto result = PartPtrOpt();
|
||||||
for (const auto &part : _parts) {
|
for (const auto &part : _parts) {
|
||||||
if (!part.item->emptyText()) {
|
if (!part.item->emptyText()) {
|
||||||
if (result) {
|
if (result) {
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
} else {
|
} else {
|
||||||
result = part.item;
|
result = ∂
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
if (captionItem) {
|
if (captionPart) {
|
||||||
_caption = createCaption(captionItem);
|
const auto &part = (*captionPart);
|
||||||
|
struct Timestamp {
|
||||||
|
int duration = 0;
|
||||||
|
QString base;
|
||||||
|
};
|
||||||
|
const auto timestamp = [&]() -> Timestamp {
|
||||||
|
const auto &document = part->content->getDocument();
|
||||||
|
if (!document || document->isAnimation()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const auto duration = document->getDuration();
|
||||||
|
return {
|
||||||
|
.duration = duration,
|
||||||
|
.base = duration
|
||||||
|
? DocumentTimestampLinkBase(
|
||||||
|
document,
|
||||||
|
part->item->fullId())
|
||||||
|
: QString(),
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
_caption = createCaption(
|
||||||
|
part->item,
|
||||||
|
timestamp.duration,
|
||||||
|
timestamp.base);
|
||||||
|
|
||||||
|
_captionItem = part->item;
|
||||||
|
} else {
|
||||||
|
_captionItem = nullptr;
|
||||||
}
|
}
|
||||||
_captionItem = captionItem;
|
|
||||||
_needBubble = computeNeedBubble();
|
_needBubble = computeNeedBubble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue