mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-10 21:53:50 +00:00
Target collage spoiler at the clicked media item
This commit is contained in:
@@ -1462,7 +1462,10 @@ auto CachedPageMediaRuntime::hostedMediaBlockFactory() const
|
||||
const auto medias = std::make_shared<
|
||||
std::vector<std::unique_ptr<::Data::Media>>>();
|
||||
medias->reserve(prepared.items.size());
|
||||
for (const auto &item : prepared.items) {
|
||||
for (auto i = 0, count = int(prepared.items.size())
|
||||
; i != count
|
||||
; ++i) {
|
||||
const auto &item = prepared.items[i];
|
||||
const auto kind = item.media.kind;
|
||||
if (kind == Markdown::PreparedMediaItemKind::Photo) {
|
||||
const auto photo = session->data().photo(
|
||||
@@ -1482,6 +1485,7 @@ auto CachedPageMediaRuntime::hostedMediaBlockFactory() const
|
||||
photo,
|
||||
origin,
|
||||
host->item()->fullId()));
|
||||
descriptor.groupedItemIndices.emplace(photo->id, i);
|
||||
} else {
|
||||
const auto document = session->data().document(
|
||||
DocumentId(item.media.id));
|
||||
@@ -1504,6 +1508,7 @@ auto CachedPageMediaRuntime::hostedMediaBlockFactory() const
|
||||
document,
|
||||
origin,
|
||||
host->item()->fullId()));
|
||||
descriptor.groupedItemIndices.emplace(document->id, i);
|
||||
}
|
||||
if (!medias->back()->canBeGrouped()) {
|
||||
return std::shared_ptr<Markdown::MediaBlock>();
|
||||
|
||||
@@ -227,6 +227,7 @@ private:
|
||||
const base::flat_map<
|
||||
uint64,
|
||||
std::shared_ptr<DocumentRuntime>> _groupedDocumentRuntimes;
|
||||
const base::flat_map<uint64, int> _groupedItemIndices;
|
||||
const std::shared_ptr<IvHistoryViewMediaHost> _host;
|
||||
const std::vector<std::shared_ptr<void>> _keepAlive;
|
||||
std::unique_ptr<HistoryView::Media> _media;
|
||||
@@ -246,6 +247,7 @@ IvHistoryViewBlock::IvHistoryViewBlock(
|
||||
, _documentRuntime(std::move(descriptor.document))
|
||||
, _groupedPhotoRuntimes(std::move(descriptor.groupedPhotos))
|
||||
, _groupedDocumentRuntimes(std::move(descriptor.groupedDocuments))
|
||||
, _groupedItemIndices(std::move(descriptor.groupedItemIndices))
|
||||
, _host(std::move(descriptor.host))
|
||||
, _keepAlive(std::move(descriptor.keepAlive)) {
|
||||
if (descriptor.mediaFactory) {
|
||||
@@ -427,6 +429,11 @@ IvHistoryViewHit IvHistoryViewBlock::classifyHandler(
|
||||
if (i != end(_groupedPhotoRuntimes)) {
|
||||
result.activation.kind = MediaActivationKind::Photo;
|
||||
result.activation.photo = i->second;
|
||||
const auto j = _groupedItemIndices.find(
|
||||
photoOpen->photo()->id);
|
||||
if (j != end(_groupedItemIndices)) {
|
||||
result.activation.itemIndex = j->second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
} else if (const auto documentOpen
|
||||
@@ -436,6 +443,11 @@ IvHistoryViewHit IvHistoryViewBlock::classifyHandler(
|
||||
if (i != end(_groupedDocumentRuntimes)) {
|
||||
result.activation.kind = MediaActivationKind::Document;
|
||||
result.activation.document = i->second;
|
||||
const auto j = _groupedItemIndices.find(
|
||||
documentOpen->document()->id);
|
||||
if (j != end(_groupedItemIndices)) {
|
||||
result.activation.itemIndex = j->second;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ struct IvHistoryViewMediaDescriptor {
|
||||
base::flat_map<
|
||||
uint64,
|
||||
std::shared_ptr<DocumentRuntime>> groupedDocuments;
|
||||
base::flat_map<uint64, int> groupedItemIndices;
|
||||
};
|
||||
|
||||
class IvHistoryViewMediaBlockFactory final : public HostedMediaBlockFactory {
|
||||
|
||||
Reference in New Issue
Block a user