2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Allow sending premium emoji to Saved Messages.

This commit is contained in:
John Preston
2022-08-01 16:24:51 +03:00
parent 087074fea4
commit b42f2784ab
18 changed files with 93 additions and 39 deletions

View File

@@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "editor/photo_editor_layer_widget.h"
#include "history/history_drag_area.h"
#include "history/history_item.h"
#include "history/history.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
@@ -242,10 +243,12 @@ void EditCaptionBox::rebuildPreview() {
}
void EditCaptionBox::setupField() {
const auto peer = _historyItem->history()->peer;
InitMessageFieldHandlers(
_controller,
_field.get(),
Window::GifPauseReason::Layer);
Window::GifPauseReason::Layer,
[=](const auto&) { return Data::AllowEmojiWithoutPremium(peer); });
Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(),
_field,
@@ -488,6 +491,7 @@ void EditCaptionBox::setupEmojiPanel() {
st::emojiPanMinHeight / 2,
st::emojiPanMinHeight);
_emojiPanel->hide();
_emojiPanel->selector()->setCurrentPeer(_historyItem->history()->peer);
_emojiPanel->selector()->emojiChosen(
) | rpl::start_with_next([=](EmojiPtr emoji) {
Ui::InsertEmojiAtCursor(_field->textCursor(), emoji);

View File

@@ -250,15 +250,16 @@ SendFilesBox::SendFilesBox(
not_null<Window::SessionController*> controller,
Ui::PreparedList &&list,
const TextWithTags &caption,
SendLimit limit,
not_null<PeerData*> peer,
Api::SendType sendType,
SendMenu::Type sendMenuType)
: _controller(controller)
, _sendType(sendType)
, _titleHeight(st::boxTitleHeight)
, _list(std::move(list))
, _sendLimit(limit)
, _sendLimit(peer->slowmodeApplied() ? SendLimit::One : SendLimit::Many)
, _sendMenuType(sendMenuType)
, _allowEmojiWithoutPremium(Data::AllowEmojiWithoutPremium(peer))
, _caption(
this,
st::confirmCaptionArea,
@@ -676,7 +677,8 @@ void SendFilesBox::setupCaption() {
InitMessageFieldHandlers(
_controller,
_caption.data(),
Window::GifPauseReason::Layer);
Window::GifPauseReason::Layer,
[=](const auto&) { return _allowEmojiWithoutPremium; });
Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(),
_caption,
@@ -730,6 +732,8 @@ void SendFilesBox::setupEmojiPanel() {
st::emojiPanMinHeight / 2,
st::emojiPanMinHeight);
_emojiPanel->hide();
_emojiPanel->selector()->setAllowEmojiWithoutPremium(
_allowEmojiWithoutPremium);
_emojiPanel->selector()->emojiChosen(
) | rpl::start_with_next([=](EmojiPtr emoji) {
Ui::InsertEmojiAtCursor(_caption->textCursor(), emoji);

View File

@@ -57,7 +57,7 @@ public:
not_null<Window::SessionController*> controller,
Ui::PreparedList &&list,
const TextWithTags &caption,
SendLimit limit,
not_null<PeerData*> peer,
Api::SendType sendType,
SendMenu::Type sendMenuType);
@@ -168,6 +168,7 @@ private:
SendLimit _sendLimit = SendLimit::Many;
SendMenu::Type _sendMenuType = SendMenu::Type();
bool _allowEmojiWithoutPremium = false;
Fn<void(
Ui::PreparedList &&list,

View File

@@ -422,13 +422,14 @@ void StickerSetBox::updateButtons() {
if (!_controller->session().premium()
&& _controller->session().premiumPossible()
&& _inner->premiumEmojiSet()) {
setStyle(st::premiumPreviewBox);
const auto &st = st::premiumPreviewDoubledLimitsBox;
setStyle(st);
auto button = CreateUnlockButton(
this,
tr::lng_premium_unlock_emoji());
button->resizeToWidth(st::boxWideWidth
- st::premiumPreviewBox.buttonPadding.left()
- st::premiumPreviewBox.buttonPadding.left());
- st.buttonPadding.left()
- st.buttonPadding.left());
button->setClickedCallback([=] {
Settings::ShowPremium(_controller, u"animated_emoji"_q);
});