mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show paid media albums with context.
This commit is contained in:
parent
54cc12cf22
commit
dfc422b505
3 changed files with 49 additions and 1 deletions
|
@ -669,6 +669,11 @@ auto GroupThumbs::createThumb(Key key)
|
||||||
key,
|
key,
|
||||||
page->collage,
|
page->collage,
|
||||||
collageKey->index);
|
collageKey->index);
|
||||||
|
} else if (const auto invoice = media->invoice()) {
|
||||||
|
return createThumb(
|
||||||
|
key,
|
||||||
|
*invoice,
|
||||||
|
collageKey->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,6 +700,23 @@ auto GroupThumbs::createThumb(
|
||||||
return createThumb(key, nullptr);
|
return createThumb(key, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto GroupThumbs::createThumb(
|
||||||
|
Key key,
|
||||||
|
const Data::Invoice &invoice,
|
||||||
|
int index)
|
||||||
|
-> std::unique_ptr<Thumb> {
|
||||||
|
if (index < 0 || index >= invoice.extendedMedia.size()) {
|
||||||
|
return createThumb(key, nullptr);
|
||||||
|
}
|
||||||
|
const auto &media = invoice.extendedMedia[index];
|
||||||
|
if (const auto photo = media->photo()) {
|
||||||
|
return createThumb(key, photo);
|
||||||
|
} else if (const auto document = media->document()) {
|
||||||
|
return createThumb(key, document);
|
||||||
|
}
|
||||||
|
return createThumb(key, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
auto GroupThumbs::createThumb(Key key, std::nullptr_t)
|
auto GroupThumbs::createThumb(Key key, std::nullptr_t)
|
||||||
-> std::unique_ptr<Thumb> {
|
-> std::unique_ptr<Thumb> {
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
|
|
|
@ -15,6 +15,10 @@ class SharedMediaWithLastSlice;
|
||||||
class UserPhotosSlice;
|
class UserPhotosSlice;
|
||||||
struct WebPageCollage;
|
struct WebPageCollage;
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
struct Invoice;
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace Main
|
} // namespace Main
|
||||||
|
@ -109,6 +113,10 @@ private:
|
||||||
Key key,
|
Key key,
|
||||||
const WebPageCollage &collage,
|
const WebPageCollage &collage,
|
||||||
int index);
|
int index);
|
||||||
|
std::unique_ptr<Thumb> createThumb(
|
||||||
|
Key key,
|
||||||
|
const Data::Invoice &invoice,
|
||||||
|
int index);
|
||||||
std::unique_ptr<Thumb> createThumb(Key key, not_null<PhotoData*> photo);
|
std::unique_ptr<Thumb> createThumb(Key key, not_null<PhotoData*> photo);
|
||||||
std::unique_ptr<Thumb> createThumb(
|
std::unique_ptr<Thumb> createThumb(
|
||||||
Key key,
|
Key key,
|
||||||
|
|
|
@ -2771,7 +2771,7 @@ auto OverlayWidget::sharedMediaType() const
|
||||||
using Type = SharedMediaType;
|
using Type = SharedMediaType;
|
||||||
if (_message) {
|
if (_message) {
|
||||||
if (const auto media = _message->media()) {
|
if (const auto media = _message->media()) {
|
||||||
if (media->webpage()) {
|
if (media->webpage() || media->invoice()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2999,6 +2999,14 @@ std::optional<OverlayWidget::CollageKey> OverlayWidget::collageKey() const {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (const auto invoice = media->invoice()) {
|
||||||
|
for (const auto &item : invoice->extendedMedia) {
|
||||||
|
if (_photo && item->photo() == _photo) {
|
||||||
|
return _photo;
|
||||||
|
} else if (_document && item->document() == _document) {
|
||||||
|
return _document;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3032,6 +3040,16 @@ void OverlayWidget::validateCollage() {
|
||||||
if (const auto media = _message->media()) {
|
if (const auto media = _message->media()) {
|
||||||
if (const auto page = media->webpage()) {
|
if (const auto page = media->webpage()) {
|
||||||
_collageData = page->collage;
|
_collageData = page->collage;
|
||||||
|
} else if (const auto invoice = media->invoice()) {
|
||||||
|
auto &data = *_collageData;
|
||||||
|
data.items.reserve(invoice->extendedMedia.size());
|
||||||
|
for (const auto &item : invoice->extendedMedia) {
|
||||||
|
if (const auto photo = item->photo()) {
|
||||||
|
data.items.push_back(photo);
|
||||||
|
} else if (const auto document = item->document()) {
|
||||||
|
data.items.push_back(document);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue