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

Show premium tooltip on custom topic icon selection.

This commit is contained in:
John Preston
2022-10-25 12:48:48 +04:00
parent c6bc7c3de1
commit ec0380b250
5 changed files with 41 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "history/history.h"
#include "history/view/history_view_replies_section.h"
#include "history/view/history_view_sticker_toast.h"
#include "lang/lang_keys.h"
#include "info/profile/info_profile_emoji_status_panel.h"
#include "window/window_session_controller.h"
@@ -210,6 +211,7 @@ struct IconSelector {
struct State {
std::unique_ptr<Ui::EmojiFlyAnimation> animation;
std::unique_ptr<HistoryView::StickerToast> toast;
rpl::variable<DocumentId> iconId;
QPointer<QWidget> button;
};
@@ -242,7 +244,7 @@ struct IconSelector {
const auto selector = body->add(
object_ptr<EmojiListWidget>(body, EmojiListDescriptor{
.session = &controller->session(),
.mode = EmojiListWidget::Mode::EmojiStatus,
.mode = EmojiListWidget::Mode::TopicIcon,
.controller = controller,
.paused = Window::PausedIn(
controller,
@@ -289,6 +291,18 @@ struct IconSelector {
selector->setMinimalHeight(selector->width(), height);
}, body->lifetime());
const auto showToast = [=](not_null<DocumentData*> document) {
if (!state->toast) {
state->toast = std::make_unique<HistoryView::StickerToast>(
controller,
controller->widget()->bodyWidget(),
[=] { state->toast = nullptr; });
}
state->toast->showFor(
document,
HistoryView::StickerToast::Section::TopicIcon);
};
selector->customChosen(
) | rpl::start_with_next([=](ChatHelpers::FileChosen data) {
const auto owner = &controller->session().data();
@@ -298,8 +312,7 @@ struct IconSelector {
const auto premium = custom
&& !ranges::contains(document->owner().forumIcons().list(), id);
if (premium && !controller->session().premium()) {
// #TODO forum premium promo
ShowPremiumPreviewBox(controller, PremiumPreview::EmojiStatus);
showToast(document);
return;
}
const auto body = controller->window().widget()->bodyWidget();