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