mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-20 18:28:11 +00:00
Skip premium effect for nopremium stickers.
This commit is contained in:
parent
de31c1cf0c
commit
46f9bdd701
@ -150,7 +150,7 @@ messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int =
|
||||
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
|
||||
messageMediaContact#70322949 phone_number:string first_name:string last_name:string vcard:string user_id:long = MessageMedia;
|
||||
messageMediaUnsupported#9f84f49e = MessageMedia;
|
||||
messageMediaDocument#9cb070d7 flags:# document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaDocument#9cb070d7 flags:# nopremium:flags.3?true document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia;
|
||||
messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia;
|
||||
messageMediaGame#fdb19008 game:Game = MessageMedia;
|
||||
@ -1386,7 +1386,7 @@ payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice;
|
||||
|
||||
messages.transcribedAudio#93752c52 flags:# pending:flags.0?true transcription_id:long text:string = messages.TranscribedAudio;
|
||||
|
||||
help.premiumPromo#3f7ae6ee status_text:string status_entities:Vector<MessageEntity> video_sections:Vector<string> videos:Vector<Document> = help.PremiumPromo;
|
||||
help.premiumPromo#e0360f1b status_text:string status_entities:Vector<MessageEntity> video_sections:Vector<string> videos:Vector<Document> currency:string monthly_amount:long = help.PremiumPromo;
|
||||
|
||||
---functions---
|
||||
|
||||
|
@ -635,10 +635,12 @@ std::unique_ptr<HistoryView::Media> MediaPhoto::createView(
|
||||
|
||||
MediaFile::MediaFile(
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<DocumentData*> document)
|
||||
not_null<DocumentData*> document,
|
||||
bool skipPremiumEffect)
|
||||
: Media(parent)
|
||||
, _document(document)
|
||||
, _emoji(document->sticker() ? document->sticker()->alt : QString()) {
|
||||
, _emoji(document->sticker() ? document->sticker()->alt : QString())
|
||||
, _skipPremiumEffect(skipPremiumEffect) {
|
||||
parent->history()->owner().registerDocumentItem(_document, parent);
|
||||
|
||||
if (!_emoji.isEmpty()) {
|
||||
@ -658,7 +660,10 @@ MediaFile::~MediaFile() {
|
||||
}
|
||||
|
||||
std::unique_ptr<Media> MediaFile::clone(not_null<HistoryItem*> parent) {
|
||||
return std::make_unique<MediaFile>(parent, _document);
|
||||
return std::make_unique<MediaFile>(
|
||||
parent,
|
||||
_document,
|
||||
!_document->session().premium());
|
||||
}
|
||||
|
||||
DocumentData *MediaFile::document() const {
|
||||
@ -953,6 +958,7 @@ std::unique_ptr<HistoryView::Media> MediaFile::createView(
|
||||
std::make_unique<HistoryView::Sticker>(
|
||||
message,
|
||||
_document,
|
||||
_skipPremiumEffect,
|
||||
replacing));
|
||||
} else if (_document->isAnimation()
|
||||
|| _document->isVideoFile()
|
||||
|
@ -185,7 +185,8 @@ class MediaFile final : public Media {
|
||||
public:
|
||||
MediaFile(
|
||||
not_null<HistoryItem*> parent,
|
||||
not_null<DocumentData*> document);
|
||||
not_null<DocumentData*> document,
|
||||
bool skipPremiumEffect);
|
||||
~MediaFile();
|
||||
|
||||
std::unique_ptr<Media> clone(not_null<HistoryItem*> parent) override;
|
||||
@ -218,6 +219,7 @@ public:
|
||||
private:
|
||||
not_null<DocumentData*> _document;
|
||||
QString _emoji;
|
||||
bool _skipPremiumEffect = false;
|
||||
|
||||
};
|
||||
|
||||
|
@ -534,7 +534,11 @@ HistoryMessage::HistoryMessage(
|
||||
postAuthor,
|
||||
std::move(markup));
|
||||
|
||||
_media = std::make_unique<Data::MediaFile>(this, document);
|
||||
const auto skipPremiumEffect = !history->session().premium();
|
||||
_media = std::make_unique<Data::MediaFile>(
|
||||
this,
|
||||
document,
|
||||
skipPremiumEffect);
|
||||
setText(caption);
|
||||
}
|
||||
|
||||
@ -1173,7 +1177,8 @@ std::unique_ptr<Data::Media> HistoryMessage::CreateMedia(
|
||||
return document->match([&](const MTPDdocument &document) -> Result {
|
||||
return std::make_unique<Data::MediaFile>(
|
||||
item,
|
||||
item->history()->owner().processDocument(document));
|
||||
item->history()->owner().processDocument(document),
|
||||
media.is_nopremium());
|
||||
}, [](const MTPDdocumentEmpty &) -> Result {
|
||||
return nullptr;
|
||||
});
|
||||
|
@ -565,12 +565,14 @@ void Element::refreshMedia(Element *replacing) {
|
||||
&& Core::App().settings().largeEmoji()) {
|
||||
const auto emoji = _data->isolatedEmoji();
|
||||
const auto emojiStickers = &session->emojiStickersPack();
|
||||
const auto skipPremiumEffect = false;
|
||||
if (const auto sticker = emojiStickers->stickerForEmoji(emoji)) {
|
||||
_media = std::make_unique<UnwrappedMedia>(
|
||||
this,
|
||||
std::make_unique<Sticker>(
|
||||
this,
|
||||
sticker.document,
|
||||
skipPremiumEffect,
|
||||
replacing,
|
||||
sticker.replacements));
|
||||
} else {
|
||||
|
@ -34,7 +34,8 @@ Dice::Dice(not_null<Element*> parent, not_null<Data::MediaDice*> dice)
|
||||
, _dice(dice)
|
||||
, _link(dice->makeHandler()) {
|
||||
if (const auto document = Lookup(parent, dice->emoji(), 0)) {
|
||||
_start.emplace(parent, document);
|
||||
const auto skipPremiumEffect = false;
|
||||
_start.emplace(parent, document, skipPremiumEffect);
|
||||
_start->setDiceIndex(_dice->emoji(), 0);
|
||||
}
|
||||
_showLastFrame = _parent->data()->Has<HistoryMessageForwarded>();
|
||||
@ -56,14 +57,16 @@ ClickHandlerPtr Dice::link() {
|
||||
void Dice::draw(Painter &p, const PaintContext &context, const QRect &r) {
|
||||
if (!_start) {
|
||||
if (const auto document = Lookup(_parent, _dice->emoji(), 0)) {
|
||||
_start.emplace(_parent, document);
|
||||
const auto skipPremiumEffect = false;
|
||||
_start.emplace(_parent, document, skipPremiumEffect);
|
||||
_start->setDiceIndex(_dice->emoji(), 0);
|
||||
_start->initSize();
|
||||
}
|
||||
}
|
||||
if (const auto value = _end ? 0 : _dice->value()) {
|
||||
if (const auto document = Lookup(_parent, _dice->emoji(), value)) {
|
||||
_end.emplace(_parent, document);
|
||||
const auto skipPremiumEffect = false;
|
||||
_end.emplace(_parent, document, skipPremiumEffect);
|
||||
_end->setDiceIndex(_dice->emoji(), value);
|
||||
_end->initSize();
|
||||
}
|
||||
|
@ -78,9 +78,13 @@ std::unique_ptr<Media> CreateAttach(
|
||||
return std::make_unique<GroupedMedia>(parent, collage);
|
||||
} else if (document) {
|
||||
if (document->sticker()) {
|
||||
const auto skipPremiumEffect = false;
|
||||
return std::make_unique<UnwrappedMedia>(
|
||||
parent,
|
||||
std::make_unique<Sticker>(parent, document));
|
||||
std::make_unique<Sticker>(
|
||||
parent,
|
||||
document,
|
||||
skipPremiumEffect));
|
||||
} else if (document->isAnimation() || document->isVideoFile()) {
|
||||
return std::make_unique<Gif>(parent, parent->data(), document);
|
||||
} else if (document->isWallPaper() || document->isTheme()) {
|
||||
|
@ -99,7 +99,8 @@ void SlotMachine::resolve(
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
sticker.emplace(_parent, document);
|
||||
const auto skipPremiumEffect = false;
|
||||
sticker.emplace(_parent, document, skipPremiumEffect);
|
||||
sticker->setDiceIndex(kEmoji, singleTimeIndex);
|
||||
if (initSize) {
|
||||
sticker->initSize();
|
||||
|
@ -61,16 +61,18 @@ constexpr auto kEmojiMultiplier = 3;
|
||||
Sticker::Sticker(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> data,
|
||||
bool skipPremiumEffect,
|
||||
Element *replacing,
|
||||
const Lottie::ColorReplacements *replacements)
|
||||
: _parent(parent)
|
||||
, _data(data)
|
||||
, _replacements(replacements) {
|
||||
, _replacements(replacements)
|
||||
, _skipPremiumEffect(skipPremiumEffect) {
|
||||
if ((_dataMedia = _data->activeMediaView())) {
|
||||
dataMediaCreated();
|
||||
} else {
|
||||
_data->loadThumbnail(parent->data()->fullId());
|
||||
if (_data->isPremiumSticker()) {
|
||||
if (hasPremiumEffect()) {
|
||||
_data->loadVideoThumbnail(parent->data()->fullId());
|
||||
}
|
||||
}
|
||||
@ -78,8 +80,7 @@ Sticker::Sticker(
|
||||
_lottie = media->stickerTakeLottie(_data, _replacements);
|
||||
if (_lottie) {
|
||||
//_externalInfo = media->externalLottieInfo();
|
||||
if (_data->isPremiumSticker()
|
||||
&& !_premiumEffectPlayed) {
|
||||
if (hasPremiumEffect() && !_premiumEffectPlayed) {
|
||||
_premiumEffectPlayed = true;
|
||||
_parent->delegate()->elementStartPremium(_parent, replacing);
|
||||
}
|
||||
@ -100,6 +101,10 @@ Sticker::~Sticker() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Sticker::hasPremiumEffect() const {
|
||||
return !_skipPremiumEffect && _data->isPremiumSticker();
|
||||
}
|
||||
|
||||
bool Sticker::isEmojiSticker() const {
|
||||
return (_parent->data()->media() == nullptr);
|
||||
}
|
||||
@ -134,7 +139,7 @@ bool Sticker::readyToDrawLottie() {
|
||||
ensureDataMediaCreated();
|
||||
_dataMedia->checkStickerLarge();
|
||||
const auto loaded = _dataMedia->loaded();
|
||||
const auto waitingForPremium = _data->isPremiumSticker()
|
||||
const auto waitingForPremium = hasPremiumEffect()
|
||||
&& _dataMedia->videoThumbnailContent().isEmpty();
|
||||
if (sticker->isLottie() && !_lottie && loaded && !waitingForPremium) {
|
||||
setupLottie();
|
||||
@ -338,7 +343,7 @@ QPixmap Sticker::paintedPixmap(const PaintContext &context) const {
|
||||
}
|
||||
|
||||
bool Sticker::mirrorHorizontal() const {
|
||||
if (!_data->isPremiumSticker()) {
|
||||
if (!hasPremiumEffect()) {
|
||||
return false;
|
||||
}
|
||||
const auto rightAligned = _parent->hasOutLayout()
|
||||
@ -368,7 +373,7 @@ void Sticker::refreshLink() {
|
||||
}
|
||||
});
|
||||
} else if (sticker && sticker->set) {
|
||||
if (_data->isPremiumSticker()) {
|
||||
if (hasPremiumEffect()) {
|
||||
const auto weak = base::make_weak(this);
|
||||
_link = std::make_shared<LambdaClickHandler>([weak] {
|
||||
if (const auto that = weak.get()) {
|
||||
@ -423,7 +428,7 @@ void Sticker::dataMediaCreated() const {
|
||||
if (_dataMedia->thumbnailPath().isEmpty()) {
|
||||
_dataMedia->thumbnailWanted(_parent->data()->fullId());
|
||||
}
|
||||
if (_data->isPremiumSticker()) {
|
||||
if (hasPremiumEffect()) {
|
||||
_data->loadVideoThumbnail(_parent->data()->fullId());
|
||||
}
|
||||
_parent->history()->owner().registerHeavyViewPart(_parent);
|
||||
@ -448,7 +453,7 @@ void Sticker::setupLottie() {
|
||||
}
|
||||
|
||||
void Sticker::checkPremiumEffectStart() {
|
||||
if (!_premiumEffectPlayed && _data->isPremiumSticker()) {
|
||||
if (!_premiumEffectPlayed && hasPremiumEffect()) {
|
||||
_premiumEffectPlayed = true;
|
||||
_parent->delegate()->elementStartPremium(_parent, nullptr);
|
||||
}
|
||||
@ -488,7 +493,7 @@ void Sticker::unloadLottie() {
|
||||
_lottieOncePlayed = false;
|
||||
}
|
||||
_lottie = nullptr;
|
||||
if (_data->isPremiumSticker()) {
|
||||
if (hasPremiumEffect()) {
|
||||
_parent->delegate()->elementCancelPremium(_parent);
|
||||
}
|
||||
_parent->checkHeavyPart();
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
Sticker(
|
||||
not_null<Element*> parent,
|
||||
not_null<DocumentData*> data,
|
||||
bool skipPremiumEffect,
|
||||
Element *replacing = nullptr,
|
||||
const Lottie::ColorReplacements *replacements = nullptr);
|
||||
~Sticker();
|
||||
@ -87,6 +88,7 @@ public:
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool hasPremiumEffect() const;
|
||||
[[nodiscard]] bool isEmojiSticker() const;
|
||||
void paintLottie(Painter &p, const PaintContext &context, const QRect &r);
|
||||
bool paintPixmap(Painter &p, const PaintContext &context, const QRect &r);
|
||||
@ -121,6 +123,7 @@ private:
|
||||
mutable bool _lottieOncePlayed = false;
|
||||
mutable bool _premiumEffectPlayed = false;
|
||||
mutable bool _nextLastDiceFrame = false;
|
||||
bool _skipPremiumEffect = false;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
@ -60,9 +60,11 @@ std::vector<std::unique_ptr<Data::Media>> PrepareCollageMedia(
|
||||
result.reserve(data.items.size());
|
||||
for (const auto &item : data.items) {
|
||||
if (const auto document = std::get_if<DocumentData*>(&item)) {
|
||||
const auto skipPremiumEffect = false;
|
||||
result.push_back(std::make_unique<Data::MediaFile>(
|
||||
parent,
|
||||
*document));
|
||||
*document,
|
||||
skipPremiumEffect));
|
||||
} else if (const auto photo = std::get_if<PhotoData*>(&item)) {
|
||||
result.push_back(std::make_unique<Data::MediaPhoto>(
|
||||
parent,
|
||||
|
Loading…
Reference in New Issue
Block a user