2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Improve premium preview from emoji panel.

This commit is contained in:
John Preston
2022-07-22 20:37:12 +03:00
parent 19f89b1d87
commit bb8f8131e4
3 changed files with 22 additions and 6 deletions

View File

@@ -65,6 +65,7 @@ struct Descriptor {
base::flat_map<QString, ReactionDisableType> disabled;
bool fromSettings = false;
Fn<void()> hiddenCallback;
Fn<void(not_null<Ui::BoxContent*>)> shownCallback;
};
bool operator==(const Descriptor &a, const Descriptor &b) {
@@ -1516,7 +1517,11 @@ void Show(
const Descriptor &descriptor,
const std::shared_ptr<Data::DocumentMedia> &media,
QImage back) {
controller->show(Box(PreviewBox, controller, descriptor, media, back));
const auto box = controller->show(
Box(PreviewBox, controller, descriptor, media, back));
if (descriptor.shownCallback) {
descriptor.shownCallback(box);
}
}
void Show(not_null<Window::SessionController*> controller, QImage back) {
@@ -1539,7 +1544,10 @@ void Show(
not_null<Window::SessionController*> controller,
Descriptor &&descriptor) {
if (!controller->session().premiumPossible()) {
controller->show(Box(PremiumUnavailableBox));
const auto box = controller->show(Box(PremiumUnavailableBox));
if (descriptor.shownCallback) {
descriptor.shownCallback(box);
}
return;
}
auto &list = Preloads();
@@ -1616,10 +1624,12 @@ void ShowStickerPreviewBox(
void ShowPremiumPreviewBox(
not_null<Window::SessionController*> controller,
PremiumPreview section,
const base::flat_map<QString, ReactionDisableType> &disabled) {
const base::flat_map<QString, ReactionDisableType> &disabled,
Fn<void(not_null<Ui::BoxContent*>)> shown) {
Show(controller, Descriptor{
.section = section,
.disabled = disabled,
.shownCallback = std::move(shown),
});
}